testautoi 0.9.142 → 0.9.143
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/calabash-ios-build.rb +2 -2
- data/bin/calabash-ios-setup.rb +16 -9
- data/bin/testautoi +21 -8
- data/calabash-cucumber.gemspec +2 -2
- data/features-skeleton/support/01_launch.rb +46 -0
- data/features-skeleton/support/{hooks.rb → 02_pre_stop_hooks.rb} +0 -0
- data/features/step_definitions/calabash_steps.rb +14 -5
- data/lib/calabash-cucumber/core.rb +22 -4
- data/lib/calabash-cucumber/device.rb +84 -0
- data/lib/calabash-cucumber/launch/simulator_helper.rb +8 -14
- data/lib/calabash-cucumber/launcher.rb +20 -9
- data/lib/calabash-cucumber/operations.rb +7 -1
- data/lib/calabash-cucumber/version.rb +2 -2
- data/lib/calabash-cucumber/wait_helpers.rb +17 -9
- data/scripts/launch.rb +11 -20
- metadata +7 -7
- data/features-skeleton/support/launch.rb +0 -77
data/bin/calabash-ios-build.rb
CHANGED
@@ -48,8 +48,8 @@ def console
|
|
48
48
|
path = ENV['CALABASH_IRBRC']
|
49
49
|
unless path
|
50
50
|
path = File.expand_path(File.join(@script_dir,".irbrc"))
|
51
|
-
ENV['IRBRC'] = path
|
52
51
|
end
|
52
|
+
ENV['IRBRC'] = path
|
53
53
|
puts "Running irb..."
|
54
54
|
exec("irb")
|
55
55
|
end
|
@@ -93,4 +93,4 @@ def run(options={:build_dir=>"Calabash",
|
|
93
93
|
end
|
94
94
|
system(cmd)
|
95
95
|
puts "Done..."
|
96
|
-
end
|
96
|
+
end
|
data/bin/calabash-ios-setup.rb
CHANGED
@@ -297,7 +297,7 @@ def update(args)
|
|
297
297
|
if args.length > 0
|
298
298
|
target = args[0]
|
299
299
|
unless UPDATE_TARGETS.include?(target)
|
300
|
-
msg(
|
300
|
+
msg('Error') do
|
301
301
|
puts "Invalid target #{target}. Must be one of: #{UPDATE_TARGETS.join(' ')}"
|
302
302
|
end
|
303
303
|
exit 1
|
@@ -305,8 +305,8 @@ def update(args)
|
|
305
305
|
|
306
306
|
|
307
307
|
|
308
|
-
target_file =
|
309
|
-
msg(
|
308
|
+
target_file = 'features/support/launch.rb'
|
309
|
+
msg('Question') do
|
310
310
|
puts "I'm about to update the #{target_file} file."
|
311
311
|
puts "Please hit return to confirm that's what you want."
|
312
312
|
end
|
@@ -314,22 +314,29 @@ def update(args)
|
|
314
314
|
|
315
315
|
|
316
316
|
unless File.exist?(target_file)
|
317
|
-
msg(
|
317
|
+
msg('Error') do
|
318
318
|
puts "Unable to find file #{target_file}"
|
319
319
|
puts "Please change directory so that #{target_file} exists."
|
320
320
|
end
|
321
321
|
exit 1
|
322
322
|
end
|
323
|
-
new_launch_script = File.join(@script_dir,
|
323
|
+
new_launch_script = File.join(@script_dir, 'launch.rb')
|
324
324
|
|
325
|
-
FileUtils.cp(new_launch_script,
|
325
|
+
FileUtils.cp(new_launch_script, 'features/support/01_launch.rb', :verbose => true)
|
326
|
+
FileUtils.rm(target_file, :force => true, :verbose => true)
|
326
327
|
|
327
|
-
|
328
|
+
hooks_file = 'features/support/hooks.rb'
|
329
|
+
if File.exist?(hooks_file)
|
330
|
+
FileUtils.mv(hooks_file, 'features/support/02_pre_stop_hooks.rb', :verbose => true)
|
331
|
+
end
|
332
|
+
|
333
|
+
msg('Info') do
|
328
334
|
puts "File copied.\n"
|
329
|
-
puts
|
335
|
+
puts 'Launch on device using environment variable DEVICE_TARGET=device.'
|
336
|
+
puts 'Launch on simulator by default or using environment variable DEVICE_TARGET=simulator.'
|
330
337
|
end
|
331
338
|
else
|
332
|
-
msg(
|
339
|
+
msg('Error') do
|
333
340
|
puts "update must take one of the following targets: #{UPDATE_TARGETS.join(' ')}"
|
334
341
|
end
|
335
342
|
exit 1
|
data/bin/testautoi
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'zip/zip'
|
3
4
|
require 'fileutils'
|
4
5
|
require 'json'
|
5
6
|
require 'tmpdir'
|
6
|
-
require 'zip/zip'
|
7
7
|
require 'uri'
|
8
8
|
|
9
9
|
require File.join(File.dirname(__FILE__),"calabash-ios-sim")
|
@@ -112,6 +112,7 @@ def run(option)
|
|
112
112
|
cmd = "cucumber #{arguments.join(" ")}"
|
113
113
|
end
|
114
114
|
env = {}
|
115
|
+
env['CALABASH_NO_DEPRECATION'] = '1'
|
115
116
|
env["APP_BUNDLE_PATH"] = File.join(FileUtils.pwd, app_bundle)
|
116
117
|
if device_udid == ''
|
117
118
|
# Use a Simulator
|
@@ -164,8 +165,8 @@ def setup
|
|
164
165
|
ask_for_setting("sim_version", "Please enter the version of the Simulator [5.0, 5.1, 6.0, 6.1]", @settings["sim_version"])
|
165
166
|
ask_for_setting("sim_device", "Please enter the device of the Simulator [iphone, ipad]", @settings["sim_device"])
|
166
167
|
|
167
|
-
@settings["build_drop_branch_dir"] = "Mobile/iPhone/branch"
|
168
|
-
@settings["build_drop_trunk_dir"] = "Mobile/iPhone/trunk"
|
168
|
+
@settings["build_drop_branch_dir"] = "Mobile/iPhone/branch/Corp"
|
169
|
+
@settings["build_drop_trunk_dir"] = "Mobile/iPhone/trunk/Corp"
|
169
170
|
|
170
171
|
open(@settings_file, 'w') do |f|
|
171
172
|
f.puts @settings.to_json
|
@@ -302,10 +303,10 @@ def get_build(version, sim)
|
|
302
303
|
sim = (sim == 'sim')?"Emulator":"Device"
|
303
304
|
if version == 'trunk'
|
304
305
|
# copy the trunk build
|
305
|
-
release_path = File.join(mount_node, @settings["build_drop_trunk_dir"], "ConcurMobile", sim)
|
306
|
+
release_path = File.join(mount_node, @settings["build_drop_trunk_dir"], "Instrumented", "ConcurMobile-cal", sim)
|
306
307
|
else
|
307
308
|
# copy the version build
|
308
|
-
release_path = File.join(mount_node, @settings["build_drop_branch_dir"], "iPhone#{version}", "ConcurMobile", sim
|
309
|
+
release_path = File.join(mount_node, @settings["build_drop_branch_dir"], "iPhone#{version}", "Instrumented", "ConcurMobile-cal", sim)
|
309
310
|
end
|
310
311
|
raise "No builds found in #{release_path}" unless File.directory?(release_path)
|
311
312
|
build_dir = Dir.entries(release_path).reject{|d|d.start_with?('.')}.sort_by{|c| File.stat(File.join(release_path,c)).ctime}.last
|
@@ -519,12 +520,21 @@ def sim_set_pref(key, value)
|
|
519
520
|
pref_files.each do |pref_file|
|
520
521
|
plist = CFPropertyList::List.new(:file => pref_file)
|
521
522
|
hash = CFPropertyList.native_types(plist.value)
|
522
|
-
|
523
|
-
|
524
|
-
|
523
|
+
if value == nil
|
524
|
+
puts "<#{pref_file}> #{key}=#{hash[key]}"
|
525
|
+
else
|
526
|
+
puts "<#{pref_file}> #{key}=#{hash[key]} => #{value}"
|
527
|
+
hash[key] = value
|
528
|
+
plist.value = CFPropertyList.guess(hash)
|
529
|
+
plist.save(pref_file, CFPropertyList::List::FORMAT_BINARY)
|
530
|
+
end
|
525
531
|
end
|
526
532
|
end
|
527
533
|
|
534
|
+
def sim_add_photo(file)
|
535
|
+
|
536
|
+
end
|
537
|
+
|
528
538
|
class Device
|
529
539
|
def self.call_device_detect(udid = nil)
|
530
540
|
udid_arg = (udid == nil) ? "" : "-i #{udid}"
|
@@ -702,6 +712,9 @@ elsif cmd == 'sim'
|
|
702
712
|
elsif option == 'getbuild'
|
703
713
|
version = ARGV.shift
|
704
714
|
get_build(version, 'sim')
|
715
|
+
elsif option == 'add'
|
716
|
+
file = ARGV.shift
|
717
|
+
sim_add_photo(file)
|
705
718
|
end
|
706
719
|
exit 0
|
707
720
|
|
data/calabash-cucumber.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.description = %q{calabash-cucumber drives tests for native iOS apps. You must link your app with calabash-ios-server framework to execute tests.}
|
14
14
|
s.files = `git ls-files`.split("\n").concat(["staticlib/calabash.framework.zip"])
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
-
s.executables = "calabash-ios"
|
16
|
+
s.executables = ["calabash-ios", "testautoi"]
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
19
|
s.add_dependency( "cucumber" )
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_dependency( "location-one", "~>0.0.9")
|
25
25
|
s.add_dependency( "httpclient","2.3.2")
|
26
26
|
s.add_dependency( "bundler", "~> 1.1")
|
27
|
-
s.add_dependency( "run_loop", "0.0.
|
27
|
+
s.add_dependency( "run_loop", "0.0.9" )
|
28
28
|
s.add_dependency( "awesome_print")
|
29
29
|
|
30
30
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
########################################
|
2
|
+
# #
|
3
|
+
# Important Note #
|
4
|
+
# #
|
5
|
+
# When running calabash-ios tests at #
|
6
|
+
# www.xamarin.com/test-cloud #
|
7
|
+
# this file will be overwritten by #
|
8
|
+
# a file which automates #
|
9
|
+
# app launch on devices. #
|
10
|
+
# #
|
11
|
+
# Don't rely on this file being #
|
12
|
+
# present when running at #
|
13
|
+
# Xamarin Test Cloud #
|
14
|
+
# #
|
15
|
+
########################################
|
16
|
+
|
17
|
+
require 'calabash-cucumber/launcher'
|
18
|
+
|
19
|
+
|
20
|
+
# APP_BUNDLE_PATH = "~/Library/Developer/Xcode/DerivedData/??/Build/Products/Calabash-iphonesimulator/??.app"
|
21
|
+
# You may uncomment the above to overwrite the APP_BUNDLE_PATH
|
22
|
+
# However the recommended approach is to let Calabash find the app itself
|
23
|
+
# or set the environment variable APP_BUNDLE_PATH
|
24
|
+
|
25
|
+
|
26
|
+
Before do |scenario|
|
27
|
+
@calabash_launcher = Calabash::Cucumber::Launcher.new
|
28
|
+
unless @calabash_launcher.calabash_no_launch?
|
29
|
+
@calabash_launcher.relaunch
|
30
|
+
@calabash_launcher.calabash_notify(self)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
After do |scenario|
|
35
|
+
unless @calabash_launcher.calabash_no_stop?
|
36
|
+
calabash_exit
|
37
|
+
if @calabash_launcher.active?
|
38
|
+
@calabash_launcher.stop
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
at_exit do
|
44
|
+
launcher = Calabash::Cucumber::Launcher.new
|
45
|
+
Calabash::Cucumber::SimulatorHelper.stop unless launcher.calabash_no_stop?
|
46
|
+
end
|
File without changes
|
@@ -58,8 +58,17 @@ Then /^I (?:press|touch) (?:input|text) field number (\d+)$/ do |index|
|
|
58
58
|
sleep(STEP_PAUSE)
|
59
59
|
end
|
60
60
|
|
61
|
+
|
61
62
|
Then /^I (?:press|touch) the "([^\"]*)" (?:input|text) field$/ do |name|
|
62
|
-
|
63
|
+
placeholder_query = "textField placeholder:'#{name}'"
|
64
|
+
marked_query = "textField marked:'#{name}'"
|
65
|
+
if !query(placeholder_query).empty?
|
66
|
+
touch(placeholder_query)
|
67
|
+
elsif !query(marked_query).empty?
|
68
|
+
touch(marked_query)
|
69
|
+
else
|
70
|
+
screenshot_and_raise "could not find text field with placeholder '#{name}' or marked as '#{name}'"
|
71
|
+
end
|
63
72
|
sleep(STEP_PAUSE)
|
64
73
|
end
|
65
74
|
|
@@ -202,7 +211,7 @@ Then /^I wait to see a navigation bar titled "([^\"]*)"$/ do |expected_mark|
|
|
202
211
|
end
|
203
212
|
|
204
213
|
Then /^I wait for the "([^\"]*)" (?:input|text) field$/ do |placeholder|
|
205
|
-
wait_for(WAIT_TIMEOUT) { element_exists( "textField placeholder:'#{placeholder}'") }
|
214
|
+
wait_for(WAIT_TIMEOUT) { element_exists( "textField placeholder:'#{placeholder}'") || element_exists( "textField marked:'#{placeholder}'") }
|
206
215
|
end
|
207
216
|
|
208
217
|
Then /^I wait for (\d+) (?:input|text) field(?:s)?$/ do |count|
|
@@ -412,10 +421,10 @@ Then /^I see (\d+) (?:input|text) field(?:s)?$/ do |count|
|
|
412
421
|
end
|
413
422
|
|
414
423
|
Then /^I should see a "([^\"]*)" (?:input|text) field$/ do |expected_mark|
|
415
|
-
res = element_exists("textField placeholder:'#{expected_mark}'")
|
424
|
+
res = element_exists("textField placeholder:'#{expected_mark}'") ||
|
416
425
|
element_exists("textField marked:'#{expected_mark}'")
|
417
426
|
unless res
|
418
|
-
screenshot_and_raise "Expected textfield with placeholder or accessibilityLabel: #{
|
427
|
+
screenshot_and_raise "Expected textfield with placeholder or accessibilityLabel: #{expected_mark}"
|
419
428
|
end
|
420
429
|
end
|
421
430
|
|
@@ -423,7 +432,7 @@ Then /^I should not see a "([^\"]*)" (?:input|text) field$/ do |expected_mark|
|
|
423
432
|
res = query("textField placeholder:'#{expected_mark}'")
|
424
433
|
res.concat query("textField marked:'#{expected_mark}'")
|
425
434
|
unless res.empty?
|
426
|
-
screenshot_and_raise "Expected no textfield with placeholder nor accessibilityLabel: #{
|
435
|
+
screenshot_and_raise "Expected no textfield with placeholder nor accessibilityLabel: #{expected_mark}, found #{res}"
|
427
436
|
end
|
428
437
|
end
|
429
438
|
|
@@ -21,6 +21,10 @@ module Calabash
|
|
21
21
|
map(uiquery, :query, *args)
|
22
22
|
end
|
23
23
|
|
24
|
+
def flash(uiquery, *args)
|
25
|
+
map(uiquery, :flash, *args)
|
26
|
+
end
|
27
|
+
|
24
28
|
def server_version
|
25
29
|
JSON.parse(http(:path => 'version'))
|
26
30
|
end
|
@@ -49,8 +53,10 @@ module Calabash
|
|
49
53
|
end
|
50
54
|
|
51
55
|
def query_all(uiquery, *args)
|
52
|
-
|
53
|
-
|
56
|
+
unless ENV['CALABASH_NO_DEPRECATION'] == '1'
|
57
|
+
puts "query_all is deprecated. Use the new all/visible feature."
|
58
|
+
puts "see: https://github.com/calabash/calabash-ios/wiki/05-Query-syntax"
|
59
|
+
end
|
54
60
|
map("all #{uiquery}", :query, *args)
|
55
61
|
end
|
56
62
|
|
@@ -352,9 +358,17 @@ EOF
|
|
352
358
|
|
353
359
|
if data.nil? and os=="ios6"
|
354
360
|
recording = recording_name_for(recording_name, "ios5", device)
|
361
|
+
data = load_recording(recording, rec_dir)
|
362
|
+
end
|
363
|
+
|
364
|
+
if data.nil? and device=='ipad'
|
365
|
+
if ENV['FULL_CONSOLE_OUTPUT'] == '1'
|
366
|
+
puts "Unable to find recording for #{os} and #{device}. Trying with #{os} iphone"
|
367
|
+
end
|
368
|
+
recording = recording_name_for(recording_name, os, 'iphone')
|
369
|
+
data = load_recording(recording, rec_dir)
|
355
370
|
end
|
356
371
|
|
357
|
-
data = load_recording(recording, rec_dir)
|
358
372
|
|
359
373
|
if data.nil?
|
360
374
|
screenshot_and_raise "Playback not found: #{recording} (searched for #{recording} in #{Dir.pwd}, #{rec_dir}, #{DATA_PATH}/resources"
|
@@ -454,7 +468,7 @@ EOF
|
|
454
468
|
# Exiting the app shuts down the HTTP connection and generates ECONNREFUSED,
|
455
469
|
# which needs to be suppressed.
|
456
470
|
begin
|
457
|
-
http(:path => 'exit', :retryable_errors => RETRYABLE_ERRORS - [Errno::ECONNREFUSED])
|
471
|
+
http({:method =>:post, :path => 'exit', :retryable_errors => RETRYABLE_ERRORS - [Errno::ECONNREFUSED]})
|
458
472
|
rescue Errno::ECONNREFUSED
|
459
473
|
[]
|
460
474
|
end
|
@@ -492,6 +506,10 @@ EOF
|
|
492
506
|
end
|
493
507
|
end
|
494
508
|
|
509
|
+
def default_device
|
510
|
+
@calabash_launcher && @calabash_launcher.device
|
511
|
+
end
|
512
|
+
|
495
513
|
def send_uia_command(opts ={})
|
496
514
|
run_loop = opts[:run_loop] || (@calabash_launcher && @calabash_launcher.active? && @calabash_launcher.run_loop)
|
497
515
|
command = opts[:command]
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Calabash
|
4
|
+
module Cucumber
|
5
|
+
# Class device encapsulates information about the device or devices
|
6
|
+
# we are interacting with during a test.
|
7
|
+
# Credit: Due to jmoody's briar: https://github.com/jmoody/briar/blob/master/lib/briar/gestalt.rb
|
8
|
+
|
9
|
+
class Device
|
10
|
+
|
11
|
+
GESTALT_IPHONE = 'iPhone'
|
12
|
+
GESTALT_IPAD = 'iPad'
|
13
|
+
GESTALT_IPHONE5 = 'Retina 4-inch'
|
14
|
+
GESTALT_SIM_SYS = 'x86_64'
|
15
|
+
GESTALT_IPOD = 'iPod'
|
16
|
+
|
17
|
+
|
18
|
+
attr_reader :endpoint
|
19
|
+
attr_reader :device_family
|
20
|
+
attr_reader :simulator_details, :ios_version
|
21
|
+
attr_reader :system
|
22
|
+
attr_reader :framework_version
|
23
|
+
|
24
|
+
attr_accessor :udid
|
25
|
+
|
26
|
+
def initialize (endpoint, version_data)
|
27
|
+
simulator_device = version_data['simulator_device']
|
28
|
+
@endpoint = endpoint
|
29
|
+
@system = version_data['system']
|
30
|
+
@device_family = @system.eql?(GESTALT_SIM_SYS) ? simulator_device : @system.split(/[\d,.]/).first
|
31
|
+
@simulator_details = version_data['simulator']
|
32
|
+
@ios_version = version_data['iOS_version']
|
33
|
+
@framework_version = version_data['version']
|
34
|
+
end
|
35
|
+
|
36
|
+
def simulator?
|
37
|
+
system.eql?(GESTALT_SIM_SYS)
|
38
|
+
end
|
39
|
+
|
40
|
+
def device?
|
41
|
+
not simulator?
|
42
|
+
end
|
43
|
+
|
44
|
+
def iphone?
|
45
|
+
device_family.eql? GESTALT_IPHONE
|
46
|
+
end
|
47
|
+
|
48
|
+
def ipod?
|
49
|
+
device_family.eql? GESTALT_IPOD
|
50
|
+
end
|
51
|
+
|
52
|
+
def ipad?
|
53
|
+
device_family.eql? GESTALT_IPAD
|
54
|
+
end
|
55
|
+
|
56
|
+
def iphone_5?
|
57
|
+
if simulator?
|
58
|
+
simulator_details.split(/[(),]/)[3].eql? GESTALT_IPHONE5
|
59
|
+
else
|
60
|
+
system.split(/[\D]/).delete_if { |x| x.eql?('') }.first.eql?('5')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def version_hash (version_str)
|
65
|
+
tokens = version_str.split(/[,.]/)
|
66
|
+
{:major_version => tokens[0],
|
67
|
+
:minor_version => tokens[1],
|
68
|
+
:bug_version => tokens[2]}
|
69
|
+
end
|
70
|
+
|
71
|
+
def ios_major_version
|
72
|
+
version_hash(ios_version)[:major_version]
|
73
|
+
end
|
74
|
+
|
75
|
+
def ios6?
|
76
|
+
ios_major_version.eql?('6')
|
77
|
+
end
|
78
|
+
|
79
|
+
def ios5?
|
80
|
+
ios_major_version.eql?('5')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -21,7 +21,7 @@ module Calabash
|
|
21
21
|
|
22
22
|
# Load environment variable for showing full console output
|
23
23
|
# If not env var set then we use true; i.e. output to console in full
|
24
|
-
FULL_CONSOLE_OUTPUT = ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '
|
24
|
+
FULL_CONSOLE_OUTPUT = ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1' ? true : false
|
25
25
|
|
26
26
|
def self.relaunch(path, sdk = nil, version = 'iphone', args = nil)
|
27
27
|
|
@@ -89,7 +89,7 @@ module Calabash
|
|
89
89
|
msg << "i.e., the directory containing your .xcodeproj file."
|
90
90
|
msg << "In Xcode, build your calabash target for simulator."
|
91
91
|
msg << "Check that your app can be found in\n #{File.expand_path("~/Library/Developer/Xcode/DerivedData")}"
|
92
|
-
msg << "\n\nOption 2). In features/support/
|
92
|
+
msg << "\n\nOption 2). In features/support/01_launch.rb set APP_BUNDLE_PATH to"
|
93
93
|
msg << "the path where Xcode has built your Calabash target."
|
94
94
|
msg << "Alternatively you can use the environment variable APP_BUNDLE_PATH.\n"
|
95
95
|
raise msg.join("\n")
|
@@ -101,7 +101,7 @@ module Calabash
|
|
101
101
|
|
102
102
|
msg << "\nThis means that Calabash can't automatically launch iOS simulator."
|
103
103
|
msg << "Searched in Xcode 4.x default: #{DEFAULT_DERIVED_DATA_INFO}"
|
104
|
-
msg << "\nIn features/support/
|
104
|
+
msg << "\nIn features/support/01_launch.rb set APP_BUNDLE_PATH to"
|
105
105
|
msg << "the path where Xcode has built your Calabash target."
|
106
106
|
msg << "Alternatively you can use the environment variable APP_BUNDLE_PATH.\n"
|
107
107
|
raise msg.join("\n")
|
@@ -125,7 +125,7 @@ module Calabash
|
|
125
125
|
puts "Unable to find .app bundle at #{path}. It should be an .app directory."
|
126
126
|
dd_dir = derived_data_dir_for_project
|
127
127
|
app_bundles = Dir.glob(File.join(dd_dir, "Build", "Products", "*", "*.app"))
|
128
|
-
msg = "Try setting APP_BUNDLE_PATH in features/support/
|
128
|
+
msg = "Try setting APP_BUNDLE_PATH in features/support/01_launch.rb to one of:\n\n"
|
129
129
|
msg << app_bundles.join("\n")
|
130
130
|
raise msg
|
131
131
|
elsif path
|
@@ -140,7 +140,7 @@ module Calabash
|
|
140
140
|
msg << "Please build your app from Xcode"
|
141
141
|
msg << "You should build the -cal target."
|
142
142
|
msg << ""
|
143
|
-
msg << "Alternatively, specify APP_BUNDLE_PATH in features/support/
|
143
|
+
msg << "Alternatively, specify APP_BUNDLE_PATH in features/support/01_launch.rb"
|
144
144
|
msg << "This should point to the location of your built app linked with calabash.\n"
|
145
145
|
raise msg.join("\n")
|
146
146
|
end
|
@@ -151,7 +151,7 @@ module Calabash
|
|
151
151
|
msg << "Please build your app from Xcode"
|
152
152
|
msg << "You should build your calabash target."
|
153
153
|
msg << ""
|
154
|
-
msg << "Alternatively, specify APP_BUNDLE_PATH in features/support/
|
154
|
+
msg << "Alternatively, specify APP_BUNDLE_PATH in features/support/01_launch.rb"
|
155
155
|
msg << "This should point to the location of your built app linked with calabash.\n"
|
156
156
|
raise msg.join("\n")
|
157
157
|
end
|
@@ -160,7 +160,7 @@ module Calabash
|
|
160
160
|
|
161
161
|
puts "APP_BUNDLE_PATH=#{preferred_dir || sim_dirs[0]}\n\n"
|
162
162
|
puts "Please verify!"
|
163
|
-
puts "If this is wrong please set it as APP_BUNDLE_PATH in features/support/
|
163
|
+
puts "If this is wrong please set it as APP_BUNDLE_PATH in features/support/01_launch.rb\n"
|
164
164
|
puts("-"*37)
|
165
165
|
bundle_path = sim_dirs[0]
|
166
166
|
end
|
@@ -198,11 +198,6 @@ module Calabash
|
|
198
198
|
until connected
|
199
199
|
begin
|
200
200
|
connected = (ping_app == '405')
|
201
|
-
if ENV['POST_START_BREAK']
|
202
|
-
puts "Environment var POST_START_BREAK is deprecated and should no longer be necessary."
|
203
|
-
post_connect_sleep = (ENV['POST_START_BREAK'] || "2").to_f
|
204
|
-
sleep(post_connect_sleep) unless post_connect_sleep <= 0
|
205
|
-
end
|
206
201
|
if connected
|
207
202
|
server_version = get_version
|
208
203
|
if server_version
|
@@ -246,8 +241,7 @@ module Calabash
|
|
246
241
|
|
247
242
|
def self.launch(app_bundle_path, sdk, version, args = nil)
|
248
243
|
simulator = SimLauncher::Simulator.new
|
249
|
-
simulator.
|
250
|
-
simulator.launch_ios_app(app_bundle_path, sdk, version) #, args wait for update to sim launcher
|
244
|
+
simulator.launch_ios_app(app_bundle_path, sdk, version)
|
251
245
|
simulator
|
252
246
|
end
|
253
247
|
|
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'calabash-cucumber/launch/simulator_helper'
|
2
2
|
require 'sim_launcher'
|
3
|
+
require 'calabash-cucumber/device'
|
3
4
|
require 'run_loop'
|
4
5
|
|
5
6
|
|
6
7
|
class Calabash::Cucumber::Launcher
|
7
8
|
attr_accessor :run_loop
|
8
9
|
attr_accessor :device_target
|
9
|
-
attr_accessor :
|
10
|
+
attr_accessor :device
|
10
11
|
|
11
12
|
def initialize(device_target=:simulator)
|
12
13
|
self.device_target = device_target
|
@@ -16,7 +17,11 @@ class Calabash::Cucumber::Launcher
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def calabash_no_stop?
|
19
|
-
|
20
|
+
calabash_no_launch? or ENV['NO_STOP']=="1"
|
21
|
+
end
|
22
|
+
|
23
|
+
def calabash_no_launch?
|
24
|
+
ENV['NO_LAUNCH']=='1'
|
20
25
|
end
|
21
26
|
|
22
27
|
def device_target?
|
@@ -32,15 +37,23 @@ class Calabash::Cucumber::Launcher
|
|
32
37
|
end
|
33
38
|
|
34
39
|
def ios_major_version
|
35
|
-
|
36
|
-
|
40
|
+
return nil if device.nil? or device.ios_version.nil?
|
41
|
+
device.ios_major_version
|
42
|
+
end
|
43
|
+
|
44
|
+
def ios_version
|
45
|
+
return nil if device.nil?
|
46
|
+
device.ios_version
|
37
47
|
end
|
38
48
|
|
39
49
|
|
40
|
-
def reset_app_jail(sdk,
|
50
|
+
def reset_app_jail(sdk=nil, path=nil)
|
41
51
|
return if device_target?
|
42
52
|
|
43
|
-
|
53
|
+
sdk = sdk || ENV['SDK_VERSION'] || SimLauncher::SdkDetector.new().latest_sdk_version
|
54
|
+
path = path || Calabash::Cucumber::SimulatorHelper.app_bundle_or_raise(app_path)
|
55
|
+
|
56
|
+
app = File.basename(path)
|
44
57
|
bundle = `find "#{ENV['HOME']}/Library/Application Support/iPhone Simulator/#{sdk}/Applications/" -type d -depth 2 -name "#{app}" | head -n 1`
|
45
58
|
return if bundle.empty? # Assuming we're already clean
|
46
59
|
|
@@ -130,9 +143,7 @@ class Calabash::Cucumber::Launcher
|
|
130
143
|
|
131
144
|
if status=='200'
|
132
145
|
version_body = JSON.parse(res.body)
|
133
|
-
|
134
|
-
self.ios_version = version_body['iOS_version']
|
135
|
-
end
|
146
|
+
self.device = Calabash::Cucumber::Device.new(url, version_body)
|
136
147
|
end
|
137
148
|
|
138
149
|
status
|
@@ -56,7 +56,9 @@ module Calabash
|
|
56
56
|
query(uiquery, :accessibilityLabel)
|
57
57
|
end
|
58
58
|
|
59
|
-
|
59
|
+
def identifier(uiquery)
|
60
|
+
query(uiquery, :accessibilityIdentifier)
|
61
|
+
end
|
60
62
|
|
61
63
|
def simple_touch(label, *args)
|
62
64
|
touch("view marked:'#{label}'", *args)
|
@@ -71,6 +73,10 @@ module Calabash
|
|
71
73
|
end
|
72
74
|
|
73
75
|
def set_text(uiquery, txt)
|
76
|
+
unless ENV['CALABASH_NO_DEPRECATION'] == '1'
|
77
|
+
puts 'set_text is deprecated, please use keyboard_enter_text'
|
78
|
+
puts 'https://github.com/calabash/calabash-ios/wiki/03.5-Calabash-iOS-Ruby-API'
|
79
|
+
end
|
74
80
|
text_fields_modified = map(uiquery, :setText, txt)
|
75
81
|
screenshot_and_raise "could not find text field #{uiquery}" if text_fields_modified.empty?
|
76
82
|
text_fields_modified
|
@@ -82,21 +82,25 @@ module Calabash
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def wait_for_condition(options = {})
|
85
|
-
options[:timeout] = options[:timeout] ||
|
85
|
+
options[:timeout] = options[:timeout] || 30
|
86
86
|
options[:query] = options[:query] || "view"
|
87
|
+
if options.has_key?(:condition)
|
88
|
+
opt_condition = options[:condition]
|
89
|
+
if opt_condition.is_a?(Symbol)
|
90
|
+
target_condition = CALABASH_CONDITIONS[opt_condition]
|
91
|
+
elsif opt_condition.is_a?(String)
|
92
|
+
target_condition = options[:condition]
|
93
|
+
end
|
94
|
+
options[:condition] = target_condition
|
95
|
+
end
|
87
96
|
options[:condition] = options[:condition] || CALABASH_CONDITIONS[:none_animating]
|
88
97
|
options[:post_timeout] = options[:post_timeout] || 0.1
|
89
|
-
options[:frequency] = options[:frequency] || 0.
|
90
|
-
options[:retry_frequency] = options[:retry_frequency] || 0.
|
98
|
+
options[:frequency] = options[:frequency] || 0.3
|
99
|
+
options[:retry_frequency] = options[:retry_frequency] || 0.3
|
91
100
|
options[:count] = options[:count] || 2
|
92
101
|
options[:timeout_message] = options[:timeout_message] || "Timeout waiting for condition (#{options[:condition]})"
|
93
102
|
options[:screenshot_on_error] = options[:screenshot_on_error] || true
|
94
103
|
|
95
|
-
if options[:condition] == CALABASH_CONDITIONS[:none_animating]
|
96
|
-
#puts "Waiting for none-animating has been found unreliable."
|
97
|
-
#puts "You are advised not to use it until this is resolved."
|
98
|
-
#puts "Test will continue..."
|
99
|
-
end
|
100
104
|
begin
|
101
105
|
Timeout::timeout(options[:timeout],WaitError) do
|
102
106
|
loop do
|
@@ -116,11 +120,15 @@ module Calabash
|
|
116
120
|
end
|
117
121
|
|
118
122
|
def wait_for_none_animating(options = {})
|
119
|
-
#sleep(0.3)
|
120
123
|
options[:condition] = CALABASH_CONDITIONS[:none_animating]
|
121
124
|
wait_for_condition(options)
|
122
125
|
end
|
123
126
|
|
127
|
+
def wait_for_no_network_indicator(options = {})
|
128
|
+
options[:condition] = CALABASH_CONDITIONS[:no_network_indicator]
|
129
|
+
wait_for_condition(options)
|
130
|
+
end
|
131
|
+
|
124
132
|
#may be called with a string (query) or an array of strings
|
125
133
|
def wait_for_transition(done_queries, check_options={},animation_options={})
|
126
134
|
done_queries = [*done_queries]
|
data/scripts/launch.rb
CHANGED
@@ -3,47 +3,38 @@
|
|
3
3
|
# Important Note #
|
4
4
|
# #
|
5
5
|
# When running calabash-ios tests at #
|
6
|
-
# www.
|
6
|
+
# www.xamarin.com/test-cloud #
|
7
7
|
# this file will be overwritten by #
|
8
8
|
# a file which automates #
|
9
9
|
# app launch on devices. #
|
10
10
|
# #
|
11
11
|
# Don't rely on this file being #
|
12
12
|
# present when running at #
|
13
|
-
#
|
14
|
-
# #
|
15
|
-
# Only put stuff here to automate #
|
16
|
-
# iOS Simulator. #
|
17
|
-
# #
|
18
|
-
# You can put your app bundle path #
|
19
|
-
# for automating simulator app start: #
|
20
|
-
# Uncomment APP_BUNDLE_PATH =.. #
|
13
|
+
# Xamarin Test Cloud #
|
21
14
|
# #
|
22
15
|
########################################
|
23
16
|
|
24
17
|
require 'calabash-cucumber/launcher'
|
25
18
|
|
26
|
-
# Uncomment and replace ?? appropriately
|
27
|
-
# This should point to your Simulator build
|
28
|
-
# which includes calabash framework
|
29
|
-
# this is usually the Calabash build configuration
|
30
|
-
# of your production target.
|
31
|
-
#APP_BUNDLE_PATH = "~/Library/Developer/Xcode/DerivedData/??/Build/Products/Calabash-iphonesimulator/??.app"
|
32
|
-
#
|
33
19
|
|
20
|
+
# APP_BUNDLE_PATH = "~/Library/Developer/Xcode/DerivedData/??/Build/Products/Calabash-iphonesimulator/??.app"
|
21
|
+
# You may uncomment the above to overwrite the APP_BUNDLE_PATH
|
22
|
+
# However the recommended approach is to let Calabash find the app itself
|
23
|
+
# or set the environment variable APP_BUNDLE_PATH
|
34
24
|
|
35
25
|
Before do |scenario|
|
36
26
|
@calabash_launcher = Calabash::Cucumber::Launcher.new
|
37
|
-
@calabash_launcher.
|
38
|
-
|
27
|
+
unless @calabash_launcher.calabash_no_launch?
|
28
|
+
@calabash_launcher.relaunch
|
29
|
+
@calabash_launcher.calabash_notify(self)
|
30
|
+
end
|
39
31
|
end
|
40
32
|
|
41
33
|
After do |scenario|
|
42
34
|
unless @calabash_launcher.calabash_no_stop?
|
35
|
+
calabash_exit
|
43
36
|
if @calabash_launcher.active?
|
44
37
|
@calabash_launcher.stop
|
45
|
-
else
|
46
|
-
Calabash::Cucumber::SimulatorHelper.stop
|
47
38
|
end
|
48
39
|
end
|
49
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testautoi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.143
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cucumber
|
@@ -146,7 +146,7 @@ dependencies:
|
|
146
146
|
requirements:
|
147
147
|
- - '='
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: 0.0.
|
149
|
+
version: 0.0.9
|
150
150
|
type: :runtime
|
151
151
|
prerelease: false
|
152
152
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -154,7 +154,7 @@ dependencies:
|
|
154
154
|
requirements:
|
155
155
|
- - '='
|
156
156
|
- !ruby/object:Gem::Version
|
157
|
-
version: 0.0.
|
157
|
+
version: 0.0.9
|
158
158
|
- !ruby/object:Gem::Dependency
|
159
159
|
name: awesome_print
|
160
160
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,14 +220,15 @@ files:
|
|
220
220
|
- features-skeleton/my_first.feature
|
221
221
|
- features-skeleton/step_definitions/calabash_steps.rb
|
222
222
|
- features-skeleton/step_definitions/my_first_steps.rb
|
223
|
+
- features-skeleton/support/01_launch.rb
|
224
|
+
- features-skeleton/support/02_pre_stop_hooks.rb
|
223
225
|
- features-skeleton/support/env.rb
|
224
|
-
- features-skeleton/support/hooks.rb
|
225
|
-
- features-skeleton/support/launch.rb
|
226
226
|
- features/step_definitions/calabash_steps.rb
|
227
227
|
- lib/calabash-cucumber.rb
|
228
228
|
- lib/calabash-cucumber/calabash_steps.rb
|
229
229
|
- lib/calabash-cucumber/core.rb
|
230
230
|
- lib/calabash-cucumber/cucumber.rb
|
231
|
+
- lib/calabash-cucumber/device.rb
|
231
232
|
- lib/calabash-cucumber/ibase.rb
|
232
233
|
- lib/calabash-cucumber/keyboard_helpers.rb
|
233
234
|
- lib/calabash-cucumber/launch/simulator_helper.rb
|
@@ -348,4 +349,3 @@ specification_version: 3
|
|
348
349
|
summary: Summary
|
349
350
|
test_files:
|
350
351
|
- features/step_definitions/calabash_steps.rb
|
351
|
-
has_rdoc:
|
@@ -1,77 +0,0 @@
|
|
1
|
-
########################################
|
2
|
-
# #
|
3
|
-
# Important Note #
|
4
|
-
# #
|
5
|
-
# When running calabash-ios tests at #
|
6
|
-
# www.lesspainful.com #
|
7
|
-
# this file will be overwritten by #
|
8
|
-
# a file which automates #
|
9
|
-
# app launch on devices. #
|
10
|
-
# #
|
11
|
-
# Don't rely on this file being #
|
12
|
-
# present when running at #
|
13
|
-
# www.lesspainful.com. #
|
14
|
-
# #
|
15
|
-
# Only put stuff here to automate #
|
16
|
-
# iOS Simulator. #
|
17
|
-
# #
|
18
|
-
# You can put your app bundle path #
|
19
|
-
# for automating simulator app start: #
|
20
|
-
# Uncomment APP_BUNDLE_PATH =.. #
|
21
|
-
# #
|
22
|
-
########################################
|
23
|
-
|
24
|
-
require 'calabash-cucumber/launch/simulator_helper'
|
25
|
-
require 'sim_launcher'
|
26
|
-
|
27
|
-
# Uncomment and replace ?? appropriately
|
28
|
-
# This should point to your Simulator build
|
29
|
-
# which includes calabash framework
|
30
|
-
# this is usually the Calabash build configuration
|
31
|
-
# of your production target.
|
32
|
-
#APP_BUNDLE_PATH = "~/Library/Developer/Xcode/DerivedData/??/Build/Products/Calabash-iphonesimulator/??.app"
|
33
|
-
#
|
34
|
-
|
35
|
-
def reset_app_jail(sdk, app_path)
|
36
|
-
app = File.basename(app_path)
|
37
|
-
bundle = `find "#{ENV['HOME']}/Library/Application Support/iPhone Simulator/#{sdk}/Applications/" -type d -depth 2 -name "#{app}" | head -n 1`
|
38
|
-
return if bundle.empty? # Assuming we're already clean
|
39
|
-
|
40
|
-
sandbox = File.dirname(bundle)
|
41
|
-
['Library', 'Documents', 'tmp'].each do |dir|
|
42
|
-
FileUtils.rm_rf(File.join(sandbox, dir))
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def relaunch(args=nil)
|
47
|
-
if ENV['NO_LAUNCH']!="1"
|
48
|
-
sdk = ENV['SDK_VERSION'] || SimLauncher::SdkDetector.new().latest_sdk_version
|
49
|
-
path = Calabash::Cucumber::SimulatorHelper.app_bundle_or_raise(app_path)
|
50
|
-
if ENV['RESET_BETWEEN_SCENARIOS']=="1"
|
51
|
-
reset_app_jail(sdk, path)
|
52
|
-
end
|
53
|
-
|
54
|
-
Calabash::Cucumber::SimulatorHelper.relaunch(path,sdk,ENV['DEVICE'] || 'iphone', args)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def app_path
|
59
|
-
ENV['APP_BUNDLE_PATH'] || (defined?(APP_BUNDLE_PATH) && APP_BUNDLE_PATH)
|
60
|
-
end
|
61
|
-
|
62
|
-
def calabash_notify
|
63
|
-
if self.respond_to?(:on_launch)
|
64
|
-
self.on_launch
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
Before do |scenario|
|
69
|
-
relaunch
|
70
|
-
calabash_notify
|
71
|
-
end
|
72
|
-
|
73
|
-
at_exit do
|
74
|
-
if ENV['NO_LAUNCH']!="1" and ENV['NO_STOP']!="1"
|
75
|
-
Calabash::Cucumber::SimulatorHelper.stop
|
76
|
-
end
|
77
|
-
end
|