calabash-cucumber 0.10.0.pre1 → 0.10.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/step_definitions/calabash_steps.rb +1 -1
- data/lib/calabash-cucumber/actions/instruments_actions.rb +15 -4
- data/lib/calabash-cucumber/actions/playback_actions.rb +12 -3
- data/lib/calabash-cucumber/connection.rb +3 -0
- data/lib/calabash-cucumber/connection_helpers.rb +4 -0
- data/lib/calabash-cucumber/core.rb +637 -83
- data/lib/calabash-cucumber/date_picker.rb +148 -29
- data/lib/calabash-cucumber/device.rb +160 -3
- data/lib/calabash-cucumber/environment_helpers.rb +91 -46
- data/lib/calabash-cucumber/failure_helpers.rb +40 -0
- data/lib/calabash-cucumber/http_helpers.rb +9 -2
- data/lib/calabash-cucumber/ibase.rb +136 -17
- data/lib/calabash-cucumber/ios7_operations.rb +13 -9
- data/lib/calabash-cucumber/ipad_1x_2x.rb +103 -48
- data/lib/calabash-cucumber/keyboard_helpers.rb +253 -144
- data/lib/calabash-cucumber/keychain_helpers.rb +46 -32
- data/lib/calabash-cucumber/launch/simulator_helper.rb +13 -12
- data/lib/calabash-cucumber/launch/simulator_launcher.rb +111 -78
- data/lib/calabash-cucumber/launcher.rb +265 -25
- data/lib/calabash-cucumber/map.rb +24 -22
- data/lib/calabash-cucumber/operations.rb +4 -160
- data/lib/calabash-cucumber/playback_helpers.rb +26 -0
- data/lib/calabash-cucumber/query_helpers.rb +12 -0
- data/lib/calabash-cucumber/rotation_helpers.rb +64 -8
- data/lib/calabash-cucumber/status_bar_helpers.rb +40 -3
- data/lib/calabash-cucumber/tests_helpers.rb +43 -14
- data/lib/calabash-cucumber/uia.rb +93 -9
- data/lib/calabash-cucumber/utils/logging.rb +30 -16
- data/lib/calabash-cucumber/utils/plist_buddy.rb +18 -19
- data/lib/calabash-cucumber/utils/simulator_accessibility.rb +41 -30
- data/lib/calabash-cucumber/utils/xctools.rb +31 -21
- data/lib/calabash-cucumber/version.rb +98 -2
- data/lib/calabash-cucumber/wait_helpers.rb +257 -77
- data/staticlib/calabash.framework.zip +0 -0
- metadata +64 -231
- data/.gitignore +0 -17
- data/CHANGES.txt +0 -1
- data/Gemfile +0 -4
- data/Rakefile +0 -72
- data/calabash-cucumber.gemspec +0 -36
- data/epl-v10.html +0 -261
- data/lib/calabash-cucumber/resources/cell_swipe_ios4_ipad.base64 +0 -51
- data/lib/calabash-cucumber/resources/cell_swipe_ios4_iphone.base64 +0 -51
- data/lib/calabash-cucumber/resources/cell_swipe_ios5_ipad.base64 +0 -74
- data/lib/calabash-cucumber/resources/cell_swipe_ios5_iphone.base64 +0 -74
- data/lib/calabash-cucumber/resources/double_tap_ios5_ipad.base64 +0 -15
- data/lib/calabash-cucumber/resources/double_tap_ios5_iphone.base64 +0 -15
- data/lib/calabash-cucumber/resources/double_tap_ios6_ipad.base64 +0 -22
- data/lib/calabash-cucumber/resources/double_tap_ios6_iphone.base64 +0 -22
- data/lib/calabash-cucumber/resources/pan_ios5_ipad.base64 +0 -199
- data/lib/calabash-cucumber/resources/pan_ios5_iphone.base64 +0 -199
- data/lib/calabash-cucumber/resources/pan_ios6_ipad.base64 +0 -206
- data/lib/calabash-cucumber/resources/pan_ios6_iphone.base64 +0 -206
- data/lib/calabash-cucumber/resources/pinch_in_ios4_ipad.base64 +0 -104
- data/lib/calabash-cucumber/resources/pinch_in_ios4_iphone.base64 +0 -104
- data/lib/calabash-cucumber/resources/pinch_in_ios5_ipad.base64 +0 -144
- data/lib/calabash-cucumber/resources/pinch_in_ios5_iphone.base64 +0 -144
- data/lib/calabash-cucumber/resources/pinch_in_ios6_ipad.base64 +0 -70
- data/lib/calabash-cucumber/resources/pinch_in_ios6_iphone.base64 +0 -70
- data/lib/calabash-cucumber/resources/pinch_out_ios5_ipad.base64 +0 -207
- data/lib/calabash-cucumber/resources/pinch_out_ios5_iphone.base64 +0 -207
- data/lib/calabash-cucumber/resources/pinch_out_ios6_ipad.base64 +0 -96
- data/lib/calabash-cucumber/resources/pinch_out_ios6_iphone.base64 +0 -96
- data/lib/calabash-cucumber/resources/rotate_left_home_down_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_down_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_down_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_down_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_left_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_left_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_left_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_left_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_right_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_right_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_right_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_right_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_up_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_up_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_up_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_up_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_down_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_down_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_down_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_down_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_left_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_left_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_left_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_left_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_right_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_right_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_right_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_right_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_up_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_up_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_up_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_up_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/swipe_down_ios5_ipad.base64 +0 -18
- data/lib/calabash-cucumber/resources/swipe_down_ios5_iphone.base64 +0 -31
- data/lib/calabash-cucumber/resources/swipe_down_ios6_ipad.base64 +0 -25
- data/lib/calabash-cucumber/resources/swipe_down_ios6_iphone.base64 +0 -25
- data/lib/calabash-cucumber/resources/swipe_left_hard_ios4_ipad.base64 +0 -15
- data/lib/calabash-cucumber/resources/swipe_left_hard_ios4_iphone.base64 +0 -15
- data/lib/calabash-cucumber/resources/swipe_left_ios4_ipad.base64 +0 -18
- data/lib/calabash-cucumber/resources/swipe_left_ios4_iphone.base64 +0 -18
- data/lib/calabash-cucumber/resources/swipe_left_ios5_ipad.base64 +0 -17
- data/lib/calabash-cucumber/resources/swipe_left_ios5_iphone.base64 +0 -34
- data/lib/calabash-cucumber/resources/swipe_left_ios6_ipad.base64 +0 -28
- data/lib/calabash-cucumber/resources/swipe_left_ios6_iphone.base64 +0 -28
- data/lib/calabash-cucumber/resources/swipe_right_hard_ios4_ipad.base64 +0 -17
- data/lib/calabash-cucumber/resources/swipe_right_hard_ios4_iphone.base64 +0 -17
- data/lib/calabash-cucumber/resources/swipe_right_ios4_ipad.base64 +0 -13
- data/lib/calabash-cucumber/resources/swipe_right_ios4_iphone.base64 +0 -13
- data/lib/calabash-cucumber/resources/swipe_right_ios5_ipad.base64 +0 -17
- data/lib/calabash-cucumber/resources/swipe_right_ios5_iphone.base64 +0 -17
- data/lib/calabash-cucumber/resources/swipe_right_ios6_ipad.base64 +0 -25
- data/lib/calabash-cucumber/resources/swipe_right_ios6_iphone.base64 +0 -25
- data/lib/calabash-cucumber/resources/swipe_up_ios5_ipad.base64 +0 -34
- data/lib/calabash-cucumber/resources/swipe_up_ios5_iphone.base64 +0 -28
- data/lib/calabash-cucumber/resources/swipe_up_ios6_ipad.base64 +0 -25
- data/lib/calabash-cucumber/resources/swipe_up_ios6_iphone.base64 +0 -25
- data/lib/calabash-cucumber/resources/touch_done_ios4_ipad.base64 +0 -7
- data/lib/calabash-cucumber/resources/touch_done_ios4_iphone.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_done_ios5_ipad.base64 +0 -7
- data/lib/calabash-cucumber/resources/touch_done_ios5_iphone.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_hold_ios5_ipad.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_hold_ios5_iphone.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_hold_ios6_ipad.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_hold_ios6_iphone.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_ios4_ipad.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_ios4_iphone.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_ios5_ipad.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_ios5_iphone.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_ios7_ipad.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_ios7_iphone.base64 +0 -9
- data/lib/calabash-cucumber/resources/wheel_down_ios4_ipad.base64 +0 -159
- data/lib/calabash-cucumber/resources/wheel_down_ios4_iphone.base64 +0 -159
- data/lib/calabash-cucumber/resources/wheel_down_ios5_ipad.base64 +0 -156
- data/lib/calabash-cucumber/resources/wheel_down_ios5_iphone.base64 +0 -156
- data/lib/calabash-cucumber/resources/wheel_up_ios4_ipad.base64 +0 -166
- data/lib/calabash-cucumber/resources/wheel_up_ios4_iphone.base64 +0 -166
- data/lib/calabash-cucumber/resources/wheel_up_ios5_ipad.base64 +0 -156
- data/lib/calabash-cucumber/resources/wheel_up_ios5_iphone.base64 +0 -156
- data/scripts/EmptyAppHack.app/Default-568h@2x.png +0 -0
- data/scripts/EmptyAppHack.app/Default.png +0 -0
- data/scripts/EmptyAppHack.app/Default@2x.png +0 -0
- data/scripts/EmptyAppHack.app/EmptyAppHack +0 -0
- data/scripts/EmptyAppHack.app/Info.plist +0 -0
- data/scripts/EmptyAppHack.app/PkgInfo +0 -1
- data/scripts/EmptyAppHack.app/en.lproj/InfoPlist.strings +0 -0
- data/scripts/com.example.plist +0 -0
- data/scripts/data/.GlobalPreferences.plist +0 -0
- data/scripts/reset_simulator.scpt +0 -0
- data/spec/bin/calabash_ios_sim_spec.rb +0 -24
- data/spec/launcher_spec.rb +0 -166
- data/spec/logging_spec.rb +0 -38
- data/spec/plist_buddy_spec.rb +0 -99
- data/spec/resources/enable-accessibility/6.1/.gitkeep +0 -0
- data/spec/resources/enable-accessibility/7.0.3-64/.gitkeep +0 -0
- data/spec/resources/enable-accessibility/7.0.3/.gitkeep +0 -0
- data/spec/resources/enable-accessibility/7.1-64/.gitkeep +0 -0
- data/spec/resources/enable-accessibility/7.1/.gitkeep +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/Default-568h@2x.png +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/Info.plist +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/LPSimpleExample-cal +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/PkgInfo +0 -1
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/InfoPlist.strings +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFirstViewController.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFirstViewController~ipad.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFourthViewController.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFourthViewController~ipad.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPSecondViewController.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPSecondViewController~ipad.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPThirdViewController.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPThirdViewController~ipad.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/first.png +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/first@2x.png +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/second.png +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/second@2x.png +0 -0
- data/spec/resources/plist_buddy/com.example.plist +0 -0
- data/spec/resources/plist_buddy/com.testing.plist +0 -18
- data/spec/simulator_accessibility_spec.rb +0 -206
- data/spec/spec_helper.rb +0 -31
- data/spec/version_spec.rb +0 -13
- data/spec/xctools_spec.rb +0 -58
@@ -5,134 +5,175 @@ require 'calabash-cucumber/utils/logging'
|
|
5
5
|
module Calabash
|
6
6
|
module Cucumber
|
7
7
|
|
8
|
-
#
|
8
|
+
# Methods to expose the runtime environment and details about the device
|
9
|
+
# under test.
|
10
|
+
#
|
11
|
+
# @note
|
12
|
+
# The `OS` environmental variable has been deprecated. It should never
|
13
|
+
# be set.
|
9
14
|
module EnvironmentHelpers
|
10
15
|
|
11
16
|
include Calabash::Cucumber::Logging
|
12
17
|
|
13
|
-
#
|
18
|
+
# Are the uia* methods available?
|
14
19
|
#
|
15
|
-
#
|
16
|
-
#
|
20
|
+
# @note
|
21
|
+
# UIAutomation is only available if the app has been launched with
|
22
|
+
# instruments.
|
23
|
+
#
|
24
|
+
# @return [Boolean] Returns true if the app has been launched with
|
25
|
+
# instruments.
|
17
26
|
def uia_available?
|
18
27
|
Calabash::Cucumber::Launcher.instruments?
|
19
28
|
end
|
20
29
|
|
21
|
-
#
|
30
|
+
# Are the uia* methods un-available?
|
31
|
+
#
|
32
|
+
# @note
|
33
|
+
# UIAutomation is only available if the app has been launched with
|
34
|
+
# instruments.
|
22
35
|
#
|
23
|
-
#
|
24
|
-
#
|
36
|
+
# @return [Boolean] Returns true if the app has been not been launched with
|
37
|
+
# instruments.
|
25
38
|
def uia_not_available?
|
26
39
|
not uia_available?
|
27
40
|
end
|
28
41
|
|
29
|
-
#
|
42
|
+
# Are we running in the Xamarin Test Cloud?
|
43
|
+
#
|
44
|
+
# @return [Boolean] Returns true if cucumber is running in the test cloud.
|
30
45
|
def xamarin_test_cloud?
|
31
46
|
ENV['XAMARIN_TEST_CLOUD'] == '1'
|
32
47
|
end
|
33
48
|
|
34
|
-
#
|
49
|
+
# Returns the default Device that is connected the current launcher.
|
50
|
+
#
|
51
|
+
# @return [Calabash::Cucumber::Device] An instance of Device.
|
35
52
|
def default_device
|
36
53
|
l = Calabash::Cucumber::Launcher.launcher_if_used
|
37
54
|
l && l.device
|
38
55
|
end
|
39
56
|
|
40
|
-
#
|
57
|
+
# Is the device under test an iPad?
|
41
58
|
#
|
42
|
-
#
|
59
|
+
# @raise [RuntimeError] if the server cannot be reached
|
60
|
+
# @return [Boolean] true if device under test is an iPad.
|
43
61
|
def ipad?
|
44
62
|
_default_device_or_create().ipad?
|
45
63
|
end
|
46
64
|
|
47
|
-
#
|
65
|
+
# Is the device under test an iPhone?
|
48
66
|
#
|
49
|
-
#
|
67
|
+
# @raise [RuntimeError] if the server cannot be reached
|
68
|
+
# @return [Boolean] true if device under test is an iPhone.
|
50
69
|
def iphone?
|
51
70
|
_default_device_or_create().iphone?
|
52
71
|
end
|
53
72
|
|
54
|
-
#
|
73
|
+
# Is the device under test an iPod?
|
55
74
|
#
|
56
|
-
#
|
75
|
+
# @raise [RuntimeError] if the server cannot be reached
|
76
|
+
# @return [Boolean] true if device under test is an iPod.
|
57
77
|
def ipod?
|
58
78
|
_default_device_or_create().ipod?
|
59
79
|
end
|
60
|
-
|
61
|
-
#
|
80
|
+
|
81
|
+
# Is the device under test an iPhone or iPod?
|
62
82
|
#
|
63
|
-
#
|
83
|
+
# @raise [RuntimeError] if the server cannot be reached
|
84
|
+
# @return [Boolean] true if device under test is an iPhone or iPod.
|
64
85
|
def device_family_iphone?
|
65
86
|
iphone? or ipod?
|
66
87
|
end
|
67
88
|
|
68
|
-
#
|
89
|
+
# Is the device under test a simulator?
|
69
90
|
#
|
70
|
-
#
|
91
|
+
# @raise [RuntimeError] if the server cannot be reached
|
92
|
+
# @return [Boolean] true if device under test is a simulator.
|
71
93
|
def simulator?
|
72
94
|
_default_device_or_create().simulator?
|
73
95
|
end
|
74
96
|
|
75
|
-
#
|
76
|
-
#
|
77
|
-
# raises an error if the server cannot be reached
|
97
|
+
# @deprecated 0.9.168 replaced with `iphone_4in?`
|
98
|
+
# @see #iphone_4in?
|
78
99
|
def iphone_5?
|
79
100
|
_deprecated('0.9.168', "use 'iphone_4in?' instead", :warn)
|
80
101
|
iphone_4in?
|
81
102
|
end
|
82
103
|
|
83
|
-
#
|
104
|
+
# Does the device under test have 4in screen?
|
84
105
|
#
|
85
|
-
#
|
106
|
+
# @raise [RuntimeError] if the server cannot be reached
|
107
|
+
# @return [Boolean] true if device under test has a 4in screen.
|
86
108
|
def iphone_4in?
|
87
109
|
_default_device_or_create().iphone_4in?
|
88
110
|
end
|
89
111
|
|
90
|
-
#
|
112
|
+
# Is the device under test running iOS 5?
|
91
113
|
#
|
92
|
-
#
|
114
|
+
# @note
|
115
|
+
# **WARNING:** The `OS` env variable has been deprecated and should
|
116
|
+
# never be set.
|
93
117
|
#
|
94
|
-
#
|
95
|
-
#
|
118
|
+
# @note
|
119
|
+
# **WARNING:* Setting the `OS` env variable will override the value returned
|
120
|
+
# by querying the device.
|
121
|
+
# @raise [RuntimeError] if the server cannot be reached
|
122
|
+
# @return [Boolean] true if device under test is running iOS 5
|
96
123
|
def ios5?
|
97
124
|
_OS_ENV.eql?(_canonical_os_version(:ios5)) || _default_device_or_create().ios5?
|
98
125
|
end
|
99
126
|
|
100
|
-
#
|
127
|
+
# Is the device under test running iOS 6?
|
101
128
|
#
|
102
|
-
#
|
129
|
+
# @note
|
130
|
+
# **WARNING:** The `OS` env variable has been deprecated and should
|
131
|
+
# never be set.
|
103
132
|
#
|
104
|
-
#
|
105
|
-
#
|
133
|
+
# @note
|
134
|
+
# **WARNING:* Setting the `OS` env variable will override the value returned
|
135
|
+
# by querying the device.
|
136
|
+
# @raise [RuntimeError] if the server cannot be reached
|
137
|
+
# @return [Boolean] true if device under test is running iOS 6
|
106
138
|
def ios6?
|
107
139
|
_OS_ENV.eql?(_canonical_os_version(:ios6)) || _default_device_or_create().ios6?
|
108
140
|
end
|
109
141
|
|
110
142
|
|
111
|
-
#
|
143
|
+
# Is the device under test running iOS 7?
|
112
144
|
#
|
113
|
-
#
|
145
|
+
# @note
|
146
|
+
# **WARNING:** The `OS` env variable has been deprecated and should
|
147
|
+
# never be set.
|
114
148
|
#
|
115
|
-
#
|
116
|
-
#
|
149
|
+
# @note
|
150
|
+
# **WARNING:* Setting the `OS` env variable will override the value returned
|
151
|
+
# by querying the device.
|
152
|
+
# @raise [RuntimeError] if the server cannot be reached
|
153
|
+
# @return [Boolean] true if device under test is running iOS 7
|
117
154
|
def ios7?
|
118
155
|
_OS_ENV.eql?(_canonical_os_version(:ios7)) || _default_device_or_create().ios7?
|
119
156
|
end
|
120
157
|
|
121
|
-
#
|
158
|
+
# Is the app that is being tested an iPhone app emulated on an iPad?
|
159
|
+
#
|
160
|
+
# @see Calabash::Cucumber::IPad
|
122
161
|
#
|
123
|
-
#
|
162
|
+
# @raise [RuntimeError] if the server cannot be reached
|
163
|
+
# @return [Boolean] true if app is being emulated on an iPad.
|
124
164
|
def iphone_app_emulated_on_ipad?
|
125
165
|
_default_device_or_create().iphone_app_emulated_on_ipad?
|
126
166
|
end
|
127
167
|
|
128
168
|
private
|
129
|
-
#
|
169
|
+
# @!visibility private
|
170
|
+
# Returns the device that is currently being tested against.
|
130
171
|
#
|
131
|
-
#
|
132
|
-
# it is defined. otherwise, creates a new
|
172
|
+
# Returns the device attr of `Calabash::Cucumber::Launcher` if
|
173
|
+
# it is defined. otherwise, creates a new `Calabash::Cucumber::Device`
|
133
174
|
# by querying the server.
|
134
|
-
#
|
135
|
-
#
|
175
|
+
# @raise [RuntimeError] if the server cannot be reached
|
176
|
+
# @return [Calabash::Cucumber::Device] an instance of Device
|
136
177
|
def _default_device_or_create
|
137
178
|
device = default_device
|
138
179
|
if device.nil?
|
@@ -141,17 +182,21 @@ module Calabash
|
|
141
182
|
device
|
142
183
|
end
|
143
184
|
|
144
|
-
#
|
185
|
+
# Returns the value of the environmental variable OS.
|
186
|
+
#
|
187
|
+
# @note
|
188
|
+
# The `OS` env has been deprecated for some time. It should never be set.
|
145
189
|
def _OS_ENV
|
146
190
|
ENV['OS']
|
147
191
|
end
|
148
192
|
|
193
|
+
# @!visibility private
|
149
194
|
CANONICAL_IOS_VERSIONS = {:ios5 => 'ios5',
|
150
195
|
:ios6 => 'ios6',
|
151
196
|
:ios7 => 'ios7'}
|
152
197
|
|
153
198
|
|
154
|
-
#
|
199
|
+
# Returns the canonical value iOS versions as strings.
|
155
200
|
def _canonical_os_version(key)
|
156
201
|
CANONICAL_IOS_VERSIONS[key]
|
157
202
|
end
|
@@ -2,8 +2,19 @@ require 'fileutils'
|
|
2
2
|
|
3
3
|
module Calabash
|
4
4
|
module Cucumber
|
5
|
+
|
6
|
+
# A collection of methods that help you handle Step failures.
|
5
7
|
module FailureHelpers
|
6
8
|
|
9
|
+
# Generates a screenshot of the app UI and saves to a file (prefer `screenshot_embed`).
|
10
|
+
# Increments a global counter of screenshots and adds the count to the filename (to ensure uniqueness).
|
11
|
+
#
|
12
|
+
# @see #screenshot_embed
|
13
|
+
# @param {Hash} options to control the details of where the screenshot is stored.
|
14
|
+
# @option options {String} :prefix (ENV['SCREENSHOT_PATH']) a prefix to prepend to the filename (e.g. 'screenshots/foo-').
|
15
|
+
# Uses ENV['SCREENSHOT_PATH'] if nil or '' if ENV['SCREENSHOT_PATH'] is nil
|
16
|
+
# @option options {String} :name ('screenshot') the base name and extension of the file (e.g. 'login.png')
|
17
|
+
# @return {String} path to the generated screenshot
|
7
18
|
def screenshot(options={:prefix => nil, :name => nil})
|
8
19
|
prefix = options[:prefix]
|
9
20
|
name = options[:name]
|
@@ -27,17 +38,46 @@ module Calabash
|
|
27
38
|
path
|
28
39
|
end
|
29
40
|
|
41
|
+
# Generates a screenshot of the app UI and embeds the screenshots in all active cucumber reporters (using `embed`).
|
42
|
+
# Increments a global counter of screenshots and adds the count to the filename (to ensure uniqueness).
|
43
|
+
#
|
44
|
+
# @param {Hash} options to control the details of where the screenshot is stored.
|
45
|
+
# @option options {String} :prefix (ENV['SCREENSHOT_PATH']) a prefix to prepend to the filename (e.g. 'screenshots/foo-').
|
46
|
+
# Uses ENV['SCREENSHOT_PATH'] if nil or '' if ENV['SCREENSHOT_PATH'] is nil
|
47
|
+
# @option options {String} :name ('screenshot') the base name and extension of the file (e.g. 'login.png')
|
48
|
+
# @option options {String} :label (uses filename) the label to use in the Cucumber reporters
|
49
|
+
# @return {String} path to the generated screenshot
|
30
50
|
def screenshot_embed(options={:prefix => nil, :name => nil, :label => nil})
|
31
51
|
path = screenshot(options)
|
32
52
|
filename = options[:label] || File.basename(path)
|
33
53
|
embed(path, 'image/png', filename)
|
34
54
|
end
|
35
55
|
|
56
|
+
# Generates a screenshot of the app UI by calling screenshot_embed and raises an error.
|
57
|
+
# Increments a global counter of screenshots and adds the count to the filename (to ensure uniqueness).
|
58
|
+
#
|
59
|
+
# @see #screenshot_embed
|
60
|
+
# @param {String} msg the message to use for the raised RuntimeError.
|
61
|
+
# @param {Hash} options to control the details of where the screenshot is stored.
|
62
|
+
# @option options {String} :prefix (ENV['SCREENSHOT_PATH']) a prefix to prepend to the filename (e.g. 'screenshots/foo-').
|
63
|
+
# Uses ENV['SCREENSHOT_PATH'] if nil or '' if ENV['SCREENSHOT_PATH'] is nil
|
64
|
+
# @option options {String} :name ('screenshot') the base name and extension of the file (e.g. 'login.png')
|
65
|
+
# @option options {String} :label (uses filename) the label to use in the Cucumber reporters
|
66
|
+
# @raise [RuntimeError] with `msg`
|
36
67
|
def screenshot_and_raise(msg, options={:prefix => nil, :name => nil, :label => nil})
|
37
68
|
screenshot_embed(options)
|
38
69
|
raise(msg)
|
39
70
|
end
|
40
71
|
|
72
|
+
# Calls `screenshot_and_raise(msg,options)`
|
73
|
+
# @see #screenshot_and_raise
|
74
|
+
# @param {String} msg the message to use for the raised RuntimeError.
|
75
|
+
# @param {Hash} options to control the details of where the screenshot is stored.
|
76
|
+
# @option options {String} :prefix (ENV['SCREENSHOT_PATH']) a prefix to prepend to the filename (e.g. 'screenshots/foo-').
|
77
|
+
# Uses ENV['SCREENSHOT_PATH'] if nil or '' if ENV['SCREENSHOT_PATH'] is nil
|
78
|
+
# @option options {String} :name ('screenshot') the base name and extension of the file (e.g. 'login.png')
|
79
|
+
# @option options {String} :label (uses filename) the label to use in the Cucumber reporters
|
80
|
+
# @raise [RuntimeError] with `msg`
|
41
81
|
def fail(msg='Error. Check log for details.', options={:prefix => nil, :name => nil, :label => nil})
|
42
82
|
screenshot_and_raise(msg, options)
|
43
83
|
end
|
@@ -2,15 +2,20 @@ require 'httpclient'
|
|
2
2
|
|
3
3
|
module Calabash
|
4
4
|
module Cucumber
|
5
|
+
|
6
|
+
# @!visibility private
|
5
7
|
module HTTPHelpers
|
6
8
|
|
9
|
+
# @!visibility private
|
7
10
|
CAL_HTTP_RETRY_COUNT=3
|
11
|
+
|
12
|
+
# @!visibility private
|
8
13
|
RETRYABLE_ERRORS = [HTTPClient::TimeoutError,
|
9
14
|
HTTPClient::KeepAliveDisconnected,
|
10
15
|
Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ECONNABORTED,
|
11
16
|
Errno::ETIMEDOUT]
|
12
17
|
|
13
|
-
|
18
|
+
# @!visibility private
|
14
19
|
def http(options, data=nil)
|
15
20
|
options[:uri] = url_for(options[:path])
|
16
21
|
options[:method] = options[:method] || :get
|
@@ -26,7 +31,7 @@ module Calabash
|
|
26
31
|
res
|
27
32
|
end
|
28
33
|
|
29
|
-
|
34
|
+
# @!visibility private
|
30
35
|
def url_for(verb)
|
31
36
|
url = URI.parse(ENV['DEVICE_ENDPOINT']|| "http://localhost:37265")
|
32
37
|
path = url.path
|
@@ -39,6 +44,7 @@ module Calabash
|
|
39
44
|
url
|
40
45
|
end
|
41
46
|
|
47
|
+
# @!visibility private
|
42
48
|
def make_http_request(options)
|
43
49
|
retryable_errors = options[:retryable_errors] || RETRYABLE_ERRORS
|
44
50
|
CAL_HTTP_RETRY_COUNT.times do |count|
|
@@ -82,6 +88,7 @@ module Calabash
|
|
82
88
|
end
|
83
89
|
end
|
84
90
|
|
91
|
+
# @!visibility private
|
85
92
|
def init_request(options={})
|
86
93
|
http = HTTPClient.new
|
87
94
|
http.connect_timeout = 30
|
@@ -1,29 +1,119 @@
|
|
1
1
|
require 'calabash-cucumber/core'
|
2
2
|
require 'calabash-cucumber/operations'
|
3
3
|
|
4
|
+
# The `IBase` class is a base class that can be used to easily implement page object classes on iOS (hence the I).
|
5
|
+
# Delegates to the cucumber World object for missing methods (e.g. embed or puts).
|
6
|
+
# Mixes in {Calabash::Cucumber::Operations}.
|
7
|
+
# For Calabash Android there is a corresponding `ABase`.
|
8
|
+
# For more detailed documentation on using the Page Object Pattern (POP) with Calabash, please see:
|
9
|
+
# {http://developer.xamarin.com/guides/testcloud/calabash/xplat-best-practices/}.
|
10
|
+
# Note we recommend using POP even if you're not targeting multiple platforms as it tends to lead to more maintainable
|
11
|
+
# test suites.
|
4
12
|
class Calabash::IBase
|
5
13
|
include Calabash::Cucumber::Operations
|
6
14
|
|
7
|
-
|
15
|
+
# A reference to the Cucumber World variable.
|
16
|
+
# @!attribute [rw] world
|
17
|
+
# @return [Object] the Cucumber World instance
|
18
|
+
attr_accessor :world
|
8
19
|
|
20
|
+
# The number of seconds to allow for page complete animations _after_ this
|
21
|
+
# page trait becomes visible.
|
22
|
+
#
|
23
|
+
# @note By default, this value is _not_ used. To use this additional
|
24
|
+
# wait time, you need to include `:await_animation => true` in the options
|
25
|
+
# hash that is passed the `await` and `transition` methods.
|
26
|
+
#
|
27
|
+
# @see #trait
|
28
|
+
# @see #await
|
29
|
+
# @see #transition
|
30
|
+
#
|
31
|
+
# @!attribute [rw] transition_duration
|
32
|
+
# @return [Number] the number of seconds to allow for page transitions
|
33
|
+
attr_accessor :transition_duration
|
34
|
+
|
35
|
+
# Create a new page object.
|
36
|
+
#
|
37
|
+
# @param [Object] world the cucumber World object
|
38
|
+
# @param [Number] transition_duration the number of seconds to for page
|
39
|
+
# transitions
|
9
40
|
def initialize(world, transition_duration=0.5)
|
10
41
|
self.world = world
|
11
42
|
self.transition_duration = transition_duration
|
12
43
|
end
|
13
44
|
|
45
|
+
# Specifies a query that recognizes this page.
|
46
|
+
#
|
47
|
+
# @abstract
|
48
|
+
# @see #await
|
49
|
+
#
|
50
|
+
# In your subclass, you have two options to implement this abstract method.
|
51
|
+
#
|
52
|
+
# 1. Override the `trait` method.
|
53
|
+
# 2. Implement a `title` method.
|
54
|
+
#
|
55
|
+
# If you implement a `title` method, this method will return:
|
56
|
+
# `"navigationItemView marked:'#{self.title}'"`
|
57
|
+
#
|
58
|
+
# @note It is recommended that you override this method method in your in
|
59
|
+
# your subclasses (option 1 below). Relying on the UINavigationBar title is
|
60
|
+
# risky because Apple's UINavigationBar API changes often.
|
61
|
+
#
|
62
|
+
# @example
|
63
|
+
# "view marked:'home'"
|
64
|
+
#
|
65
|
+
# @example
|
66
|
+
# "tableView marked:'playlist'"
|
67
|
+
#
|
68
|
+
# @example
|
69
|
+
# "button marked:'login'"
|
70
|
+
#
|
71
|
+
# @return [String] a query string that identifies this page
|
72
|
+
# @raise [RuntimeError] if the subclass does not respond to `title` or
|
73
|
+
# the subclass does not override the `trait` method
|
14
74
|
def trait
|
15
75
|
raise "You should define a trait method or a title method" unless respond_to?(:title)
|
16
76
|
"navigationItemView marked:'#{self.title}'"
|
17
77
|
end
|
18
78
|
|
79
|
+
# Returns true if the current view shows this page's `trait`.
|
80
|
+
# @see #trait
|
81
|
+
# @return [Boolean] true if `element_exists(trait)`
|
19
82
|
def current_page?
|
20
83
|
element_exists(trait)
|
21
84
|
end
|
22
85
|
|
86
|
+
# A variant of {Calabash::Cucumber::Core#page} that works inside page objects.
|
87
|
+
#
|
88
|
+
# @note It is assumed that `clz` will be a subclass of Calabash::IBase or will
|
89
|
+
# behave as such.
|
90
|
+
#
|
91
|
+
# @see Calabash::Cucumber::Core#page
|
92
|
+
# @see Calabash::IBase
|
93
|
+
# @param {Class} clz the page object class to instantiate (passing the cucumber world and `args`)
|
94
|
+
# @param {Array} args optional additional arguments to pass to the page object constructor
|
95
|
+
# @return {Object} a fresh instance of `Class clz` which has been passed a reference to the cucumber World object.
|
23
96
|
def page(clz, *args)
|
24
97
|
clz.new(world, *args)
|
25
98
|
end
|
26
99
|
|
100
|
+
# Waits for this page's `trait` to become visible.
|
101
|
+
#
|
102
|
+
# After this page appears, you can optionally wait for
|
103
|
+
# `self.transition_duration` more seconds.
|
104
|
+
#
|
105
|
+
# @see Calabash::Cucumber::WaitHelpers#wait_for_element_exists
|
106
|
+
# @see Calabash::Cucumber::WaitHelpers#wait_for
|
107
|
+
# @see #trait
|
108
|
+
# @see #transition_duration
|
109
|
+
#
|
110
|
+
# @param {Hash} wait_opts options hash to pass to `wait_for_element_exists`
|
111
|
+
# (see {Calabash::Cucumber::WaitHelpers#wait_for} and
|
112
|
+
# {Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS}).
|
113
|
+
# @option wait_opts [Boolean] :await_animation (false)
|
114
|
+
# if true, will wait for `self.transition_duration` after this page's
|
115
|
+
# `trait` appears
|
116
|
+
# @return {IBase} self
|
27
117
|
def await(wait_opts={})
|
28
118
|
wait_for_elements_exist([trait], wait_opts)
|
29
119
|
unless wait_opts.has_key?(:await_animation) && !wait_opts[:await_animation]
|
@@ -32,24 +122,53 @@ class Calabash::IBase
|
|
32
122
|
self
|
33
123
|
end
|
34
124
|
|
35
|
-
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
125
|
+
# Performs a transition from receiver page to another by performing a `tap`
|
126
|
+
# gesture or a user specified `action`.
|
127
|
+
#
|
128
|
+
# Callers must supply a hash of options `transition_options` to describe the
|
129
|
+
# transition.
|
130
|
+
#
|
131
|
+
# @note If a `tap` _and_ and `action` are defined, the `action` will be
|
132
|
+
# ignored.
|
133
|
+
#
|
134
|
+
# @note If `transition_options[:page]` is defined, then it is assumed its
|
135
|
+
# value will be a subclass of Calabash::IBase or will behave as such.
|
136
|
+
#
|
137
|
+
# @example Use this pattern to wait for `transition_duration` after the
|
138
|
+
# the target page's trait becomes visible.
|
40
139
|
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
# +:await+: If specified and truthy will await the +:page+ after performing gesture (usually to wait
|
46
|
-
# for animation to finish)
|
47
|
-
# +:tap_options+: If +:tap+ is provided used to pass as options to touch
|
48
|
-
# +:wait_options+: When awaiting target page, pass these options to the +await+ method
|
140
|
+
# opts = {:tap => "button marked:'login'",
|
141
|
+
# :wait_options => {:await_animation => true},
|
142
|
+
# :page => LoginPage}
|
143
|
+
# transition(opts)
|
49
144
|
#
|
50
|
-
#
|
145
|
+
# @param [Hash] transition_options options for controlling the transition
|
51
146
|
#
|
52
|
-
#
|
147
|
+
# @option transition_options [String] :tap
|
148
|
+
# A uiquery used to perform a tap gesture to begin transition.
|
149
|
+
#
|
150
|
+
# @option transition_options [Proc] :action
|
151
|
+
# A proc to use begin transition.
|
152
|
+
#
|
153
|
+
# @option transition_options [IBase,Class,nil] :page
|
154
|
+
# A page object or page object `class` to transition to (target page).
|
155
|
+
# If a `class` is provided it is instantiated using the `self.page` method.
|
156
|
+
# If no `page` is supplied, `self` is used.
|
157
|
+
#
|
158
|
+
# @option transition_options [Boolean] :await
|
159
|
+
# If true the `page`'s await will be called after performing the transition
|
160
|
+
# that triggers the transition. This is useful for waiting for animations to
|
161
|
+
# complete. Defaults to `true`.
|
162
|
+
#
|
163
|
+
# @option transition_options [Hash] :tap_options if a `tap` gesture is defined
|
164
|
+
# then these options will be passed to `touch`.
|
165
|
+
#
|
166
|
+
# @option transition_options [Hash] :wait_options if the :await key is true,
|
167
|
+
# then these options are passed to the `page.await` method.
|
168
|
+
#
|
169
|
+
# @return [IBase] the page that is transitioned to
|
170
|
+
# @raise [RuntimeError] if `transition_options` does not include a non-nil
|
171
|
+
# :tap or :action key
|
53
172
|
def transition(transition_options={})
|
54
173
|
uiquery = transition_options[:tap]
|
55
174
|
action = transition_options[:action]
|
@@ -84,12 +203,12 @@ class Calabash::IBase
|
|
84
203
|
page_obj
|
85
204
|
end
|
86
205
|
|
206
|
+
# @!visibility private
|
87
207
|
def await_screenshot(wait_opts={}, screenshot_opts={})
|
88
208
|
await(wait_opts)
|
89
209
|
screenshot_embed(screenshot_opts)
|
90
210
|
end
|
91
211
|
|
92
|
-
|
93
212
|
protected
|
94
213
|
def method_missing(name, *args, &block)
|
95
214
|
world.send(name, *args, &block)
|