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
@@ -1,9 +1,18 @@
|
|
1
1
|
require 'calabash-cucumber/utils/logging'
|
2
|
+
|
2
3
|
module Calabash
|
3
4
|
module Cucumber
|
4
|
-
|
5
|
+
|
6
|
+
# @!visibility public
|
7
|
+
# The Calabash iOS gem version.
|
8
|
+
VERSION = '0.10.0.pre2'
|
9
|
+
|
10
|
+
# @!visibility public
|
11
|
+
# The minimum required version of the calabash.framework or, for Xamarin
|
12
|
+
# users, the Calabash component.
|
5
13
|
MIN_SERVER_VERSION = '0.10.0.pre1'
|
6
14
|
|
15
|
+
# @!visibility private
|
7
16
|
def self.const_missing(const_name)
|
8
17
|
if const_name == :FRAMEWORK_VERSION
|
9
18
|
_deprecated('0.9.169', 'FRAMEWORK_VERSION has been deprecated - there is no replacement', :warn)
|
@@ -12,14 +21,58 @@ module Calabash
|
|
12
21
|
raise(NameError, "uninitialized constant Calabash::Cucumber::#{const_name}")
|
13
22
|
end
|
14
23
|
|
24
|
+
# A model of a release version that can be used to compare two version.
|
25
|
+
#
|
26
|
+
# Calabash tries very hard to comply with Semantic Versioning rules.
|
27
|
+
#
|
28
|
+
# However, our test workflow requires that we use `.pre` to denote
|
29
|
+
# pre-release versions instead of the recommended `-alpha`, `-beta`, or, `-pre`.
|
30
|
+
#
|
31
|
+
# Calabash version numbers will be in the form `<major>.<minor>.<patch>[.pre<N>]`.
|
32
|
+
#
|
33
|
+
# @see http://semver.org/
|
15
34
|
class Version
|
16
35
|
|
36
|
+
# @!attribute [rw] major
|
37
|
+
# @return [Integer] the major version
|
17
38
|
attr_accessor :major
|
39
|
+
|
40
|
+
# @!attribute [rw] minor
|
41
|
+
# @return [Integer] the minor version
|
18
42
|
attr_accessor :minor
|
43
|
+
|
44
|
+
# @!attribute [rw] patch
|
45
|
+
# @return [Integer] the patch version
|
19
46
|
attr_accessor :patch
|
47
|
+
|
48
|
+
# @!attribute [rw] pre
|
49
|
+
# @return [Boolean] true if this is a pre-release version
|
20
50
|
attr_accessor :pre
|
51
|
+
|
52
|
+
# @!attribute [rw] pre_version
|
53
|
+
# @return [Integer] if this is a pre-release version, returns the
|
54
|
+
# pre-release version; otherwise this is nil
|
21
55
|
attr_accessor :pre_version
|
22
56
|
|
57
|
+
# Creates a new Version instance with all the attributes set.
|
58
|
+
#
|
59
|
+
# @example
|
60
|
+
# version = Version.new(0.10.1)
|
61
|
+
# version.major => 0
|
62
|
+
# version.minor => 10
|
63
|
+
# version.patch => 1
|
64
|
+
# version.pre => false
|
65
|
+
# version.pre_release => nil
|
66
|
+
#
|
67
|
+
# @example
|
68
|
+
# version = Version.new(1.6.3.pre5)
|
69
|
+
# version.major => 1
|
70
|
+
# version.minor => 6
|
71
|
+
# version.patch => 3
|
72
|
+
# version.pre => true
|
73
|
+
# version.pre_release => 5
|
74
|
+
#
|
75
|
+
# @param [String] version the version string to parse.
|
23
76
|
def initialize(version)
|
24
77
|
tokens = version.split('.')
|
25
78
|
count = tokens.count
|
@@ -32,36 +85,64 @@ module Calabash
|
|
32
85
|
@major, @minor, @patch = version.split('.').map(&:to_i)
|
33
86
|
end
|
34
87
|
|
88
|
+
# Returns an string representation of this version.
|
89
|
+
# @return [String] a string in the form `<major>.<minor>.<patch>[.pre<N>]`
|
35
90
|
def to_s
|
36
91
|
str = [@major, @minor, @patch].join('.')
|
37
92
|
str = "#{str}.#{@pre}" if @pre
|
38
93
|
str
|
39
94
|
end
|
40
95
|
|
96
|
+
# Compare this version to another for equality.
|
97
|
+
# @param [Version] other the version to compare against
|
98
|
+
# @return [Boolean] true if this Version is the same as `other`
|
41
99
|
def == (other)
|
42
100
|
compare(self, other) == 0
|
43
101
|
end
|
44
102
|
|
103
|
+
# Compare this version to another for inequality.
|
104
|
+
# @param [Version] other the version to compare against
|
105
|
+
# @return [Boolean] true if this Version is not the same as `other`
|
45
106
|
def != (other)
|
46
107
|
compare(self, other) != 0
|
47
108
|
end
|
48
109
|
|
110
|
+
# Is this version less-than another version?
|
111
|
+
# @param [Version] other the version to compare against
|
112
|
+
# @return [Boolean] true if this Version is less-than `other`
|
49
113
|
def < (other)
|
50
114
|
compare(self, other) < 0
|
51
115
|
end
|
52
116
|
|
117
|
+
# Is this version greater-than another version?
|
118
|
+
# @param [Version] other the version to compare against
|
119
|
+
# @return [Boolean] true if this Version is greater-than `other`
|
53
120
|
def > (other)
|
54
121
|
compare(self, other) > 0
|
55
122
|
end
|
56
123
|
|
124
|
+
# Is this version less-than or equal to another version?
|
125
|
+
# @param [Version] other the version to compare against
|
126
|
+
# @return [Boolean] true if this Version is less-than or equal `other`
|
57
127
|
def <= (other)
|
58
128
|
compare(self, other) <= 0
|
59
129
|
end
|
60
130
|
|
131
|
+
# Is this version greater-than or equal to another version?
|
132
|
+
# @param [Version] other the version to compare against
|
133
|
+
# @return [Boolean] true if this Version is greater-than or equal `other`
|
61
134
|
def >= (other)
|
62
135
|
compare(self, other) >= 0
|
63
136
|
end
|
64
137
|
|
138
|
+
# Compare version `a` to version `b`.
|
139
|
+
#
|
140
|
+
# @example
|
141
|
+
# compare Version.new(0.10.0), Version.new(0.9.0) => 1
|
142
|
+
# compare Version.new(0.9.0), Version.new(0.10.0) => -1
|
143
|
+
# compare Version.new(0.9.0), Version.new(0.9.0) => 0
|
144
|
+
#
|
145
|
+
# @return [Integer] an integer `(-1, 1)`
|
65
146
|
def compare(a, b)
|
66
147
|
|
67
148
|
if a.major != b.major
|
@@ -93,12 +174,20 @@ module Calabash
|
|
93
174
|
end
|
94
175
|
end
|
95
176
|
|
177
|
+
# These are unit tests.
|
178
|
+
#
|
179
|
+
# $ ruby lib/calabash-cucumber/version.rb
|
180
|
+
#
|
181
|
+
# todo move to rspec
|
96
182
|
if __FILE__ == $0
|
97
183
|
require 'test/unit'
|
98
184
|
|
185
|
+
# @!visibility private
|
186
|
+
# Unit testing of Version class
|
99
187
|
class LocalTest < Test::Unit::TestCase
|
100
188
|
include Calabash::Cucumber
|
101
189
|
|
190
|
+
# @!visibility private
|
102
191
|
def test_version
|
103
192
|
a = Version.new('0.9.169')
|
104
193
|
assert_equal(0, a.major)
|
@@ -108,18 +197,21 @@ if __FILE__ == $0
|
|
108
197
|
assert_nil(a.pre_version)
|
109
198
|
end
|
110
199
|
|
200
|
+
# @!visibility private
|
111
201
|
def test_unnumbered_prerelease
|
112
202
|
a = Version.new('0.9.169.pre')
|
113
203
|
assert_equal('pre', a.pre)
|
114
204
|
assert_nil(a.pre_version)
|
115
205
|
end
|
116
206
|
|
207
|
+
# @!visibility private
|
117
208
|
def test_numbered_prerelease
|
118
209
|
a = Version.new('0.9.169.pre1')
|
119
210
|
assert_equal('pre1', a.pre)
|
120
211
|
assert_equal(1, a.pre_version)
|
121
212
|
end
|
122
213
|
|
214
|
+
# @!visibility private
|
123
215
|
def test_compare_equal
|
124
216
|
a = Version.new('0.9.169')
|
125
217
|
b = Version.new('0.9.169')
|
@@ -135,12 +227,12 @@ if __FILE__ == $0
|
|
135
227
|
|
136
228
|
end
|
137
229
|
|
230
|
+
# @!visibility private
|
138
231
|
def test_compare_not_equal
|
139
232
|
a = Version.new('0.9.168')
|
140
233
|
b = Version.new('0.9.169')
|
141
234
|
assert(a != b)
|
142
235
|
|
143
|
-
|
144
236
|
a = Version.new('0.9.169')
|
145
237
|
b = Version.new('0.9.169.pre1')
|
146
238
|
assert(a != b)
|
@@ -154,6 +246,7 @@ if __FILE__ == $0
|
|
154
246
|
assert(a != b)
|
155
247
|
end
|
156
248
|
|
249
|
+
# @!visibility private
|
157
250
|
def test_compare_lt
|
158
251
|
a = Version.new('0.9.168')
|
159
252
|
b = Version.new('0.9.169')
|
@@ -172,6 +265,7 @@ if __FILE__ == $0
|
|
172
265
|
assert(a < b)
|
173
266
|
end
|
174
267
|
|
268
|
+
# @!visibility private
|
175
269
|
def test_compare_gt
|
176
270
|
a = Version.new('0.9.169')
|
177
271
|
b = Version.new('0.9.168')
|
@@ -190,6 +284,7 @@ if __FILE__ == $0
|
|
190
284
|
assert(a > b)
|
191
285
|
end
|
192
286
|
|
287
|
+
# @!visibility private
|
193
288
|
def test_compare_lte
|
194
289
|
a = Version.new('0.9.168')
|
195
290
|
b = Version.new('0.9.169')
|
@@ -198,6 +293,7 @@ if __FILE__ == $0
|
|
198
293
|
assert(a <= b)
|
199
294
|
end
|
200
295
|
|
296
|
+
# @!visibility private
|
201
297
|
def test_compare_gte
|
202
298
|
a = Version.new('0.9.169')
|
203
299
|
b = Version.new('0.9.168')
|
@@ -5,28 +5,81 @@ require 'calabash-cucumber/utils/logging'
|
|
5
5
|
|
6
6
|
module Calabash
|
7
7
|
module Cucumber
|
8
|
+
|
9
|
+
# A collection of methods that help you wait for things.
|
8
10
|
module WaitHelpers
|
9
11
|
include Calabash::Cucumber::Logging
|
10
12
|
include Calabash::Cucumber::Core
|
11
13
|
include Calabash::Cucumber::TestsHelpers
|
12
14
|
|
15
|
+
# @!visibility private
|
13
16
|
CLIENT_TIMEOUT_ADDITION = 5
|
14
17
|
|
18
|
+
# `WaitError` is the error type raised
|
19
|
+
# when a timeout occurs during a wait.
|
20
|
+
# To handle a timeout without causing test failure use
|
21
|
+
# @example
|
22
|
+
# begin
|
23
|
+
# ...
|
24
|
+
# rescue Calabash::Cucumber::WaitHelpers::WaitError => e
|
25
|
+
# ...
|
26
|
+
# end
|
27
|
+
#
|
15
28
|
class WaitError < RuntimeError
|
16
29
|
end
|
17
30
|
|
18
|
-
|
19
|
-
|
31
|
+
# Currently two conditions that can be
|
32
|
+
# waited for using `wait_for_condition`: `:none_animating` no UIKit object is animating
|
33
|
+
# and `:no_network_indicator` status bar network indicator not showing.
|
34
|
+
CALABASH_CONDITIONS = {:none_animating => 'NONE_ANIMATING',
|
35
|
+
:no_network_indicator => 'NO_NETWORK_INDICATOR'}
|
20
36
|
|
21
|
-
#
|
37
|
+
# The default options used in the "wait*" methods
|
22
38
|
DEFAULT_OPTS = {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
39
|
+
# default upper limit on how long to wait
|
40
|
+
:timeout => 30,
|
41
|
+
# default polling frequency for waiting
|
42
|
+
:retry_frequency => 0.3,
|
43
|
+
# default extra wait after the condition becomes true
|
44
|
+
:post_timeout => 0,
|
45
|
+
# default message if timeout occurs
|
46
|
+
:timeout_message => 'Timed out waiting...',
|
47
|
+
# Calabash will generate a screenshot by default if waiting times out
|
48
|
+
:screenshot_on_error => true
|
28
49
|
}.freeze
|
29
50
|
|
51
|
+
# Waits for a condition to be true. The condition is specified by a given block that is called repeatedly.
|
52
|
+
# If the block returns a 'trueish' value the condition is considered true and
|
53
|
+
# `wait_for` immediately returns.
|
54
|
+
# There is a `:timeout` option that specifies a maximum number of seconds to wait.
|
55
|
+
# If the given block doesn't return a 'trueish' value before the `:timeout` seconds has elapsed,
|
56
|
+
# the waiting fails and raises a {Calabash::Cucumber::WaitHelpers::WaitError} error.
|
57
|
+
#
|
58
|
+
# The `options` hash
|
59
|
+
# controls the details of waiting (see `options_or_timeout` below).
|
60
|
+
# {Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS} specifies the default waiting options.
|
61
|
+
#
|
62
|
+
# `wait_for` is a low-level building-block for waiting and often there are higher-level
|
63
|
+
# waiting methods what use `wait_for` in their implementation (e.g. `wait_for_element_exists`).
|
64
|
+
# @see #wait_for_element_exists
|
65
|
+
#
|
66
|
+
# @example Waiting for an element (see also `wait_for_element_exists`)
|
67
|
+
# wait_for(timeout: 60,
|
68
|
+
# timeout_message: "Could not find 'Sign in' button") do
|
69
|
+
# element_exists("button marked:'Sign in'")
|
70
|
+
# end
|
71
|
+
# @param [Hash] options_or_timeout options for controlling the details of the wait.
|
72
|
+
# Note for backwards compatibility with old Calabash versions can also be a number which is
|
73
|
+
# then interpreted as a timeout.
|
74
|
+
# @option options_or_timeout [Numeric] :timeout (30) upper limit on how long to wait (in seconds)
|
75
|
+
# @option options_or_timeout [Numeric] :retry_frequency (0.3) how often to poll (i.e., call the given block)
|
76
|
+
# @option options_or_timeout [Numeric] :post_timeout (0) if positive, an extra wait is made after the condition
|
77
|
+
# is satisfied
|
78
|
+
# @option options_or_timeout [String] :timeout_message the error message to use if condition is not satisfied
|
79
|
+
# in time
|
80
|
+
# @option options_or_timeout [Boolean] :screenshot_on_error generate a screenshot on error
|
81
|
+
# @return [nil] when the condition is satisfied
|
82
|
+
# @raise [Calabash::Cucumber::WaitHelpers::WaitError] when the timeout is exceeded
|
30
83
|
def wait_for(options_or_timeout=DEFAULT_OPTS, &block)
|
31
84
|
#note Hash is preferred, number acceptable for backwards compat
|
32
85
|
default_timeout = 30
|
@@ -54,29 +107,45 @@ module Calabash
|
|
54
107
|
rescue WaitError => e
|
55
108
|
msg = timeout_message || e
|
56
109
|
if screenshot_on_error
|
57
|
-
|
58
|
-
|
110
|
+
sleep(retry_frequency)
|
111
|
+
return screenshot_and_retry(msg, &block)
|
59
112
|
else
|
60
|
-
|
61
|
-
|
113
|
+
raise wait_error(msg)
|
114
|
+
end
|
62
115
|
rescue Exception => e
|
63
116
|
handle_error_with_options(e, nil, screenshot_on_error)
|
64
117
|
end
|
65
118
|
end
|
66
119
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
120
|
+
# Repeatedly runs an action (for side-effects) until a condition is satisfied.
|
121
|
+
# Similar to `wait_for` but specifies both a condition to wait for and an action to repeatedly perform
|
122
|
+
# to make the condition true (e.g. scrolling). The return value of the action is ignored.
|
123
|
+
#
|
124
|
+
# The block represents the action and options :until or :until_exists specify the condition to wait for.
|
125
|
+
# Same options as `wait_for` can be provided.
|
126
|
+
#
|
127
|
+
# @see #wait_for
|
128
|
+
#
|
129
|
+
# @example Scrolling until we find an element
|
130
|
+
# wait_poll(timeout: 10,
|
131
|
+
# timeout_message: 'Unable to find "Example"',
|
132
|
+
# until_exists: "* marked:'Example'") do
|
133
|
+
# scroll("tableView", :down)
|
134
|
+
# end
|
135
|
+
#
|
136
|
+
# @example Win the battle
|
137
|
+
# wait_poll(timeout: 60,
|
138
|
+
# timeout_message: 'Defeat!',
|
139
|
+
# until: lambda { enemy_defeated? }) do
|
140
|
+
# launch_the_missiles!
|
141
|
+
# end
|
142
|
+
# @param [Hash] opts options for controlling the details of the wait in addition to the options specified below,
|
143
|
+
# all options in {Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS} also apply and can be overridden.
|
144
|
+
# @option opts [Proc] :until if specified this lambda/Proc becomes the condition to wait for.
|
145
|
+
# @option opts [String] :until_exists if specified, a calabash query to wait for. Exactly one of `:until` and
|
146
|
+
# `:until_exists` must be specified
|
147
|
+
# @return [nil] when the condition is satisfied
|
148
|
+
# @raise [Calabash::Cucumber::WaitHelpers::WaitError] when the timeout is exceeded
|
80
149
|
def wait_poll(opts, &block)
|
81
150
|
test = opts[:until]
|
82
151
|
if test.nil?
|
@@ -94,17 +163,72 @@ module Calabash
|
|
94
163
|
end
|
95
164
|
end
|
96
165
|
|
97
|
-
#
|
166
|
+
# Waits for a Calabash query to return a non-empty result (typically a UI element to be visible).
|
167
|
+
# Uses `wait_for`.
|
168
|
+
# @see #wait_for
|
169
|
+
# @see Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS
|
170
|
+
#
|
171
|
+
# @example Waiting for an element to be visible
|
172
|
+
# wait_for_element_exists("button marked:'foo'", timeout: 60)
|
173
|
+
# @param [String] element_query a Calabash query to wait for (i.e. `element_exists(element_query)`)
|
174
|
+
# @param [Hash] options options for controlling the details of the wait.
|
175
|
+
# The same options as {Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS} apply.
|
176
|
+
# @return [nil] when the condition is satisfied
|
177
|
+
# @raise [Calabash::Cucumber::WaitHelpers::WaitError] when the timeout is exceeded
|
178
|
+
def wait_for_element_exists(element_query, options={})
|
179
|
+
options[:timeout_message] = options[:timeout_message] || "Timeout waiting for element: #{element_query}"
|
180
|
+
wait_for(options) { element_exists(element_query) }
|
181
|
+
end
|
182
|
+
|
183
|
+
# Waits for one or more Calabash queries to all return non-empty results (typically a UI elements to be visible).
|
184
|
+
# Uses `wait_for`.
|
185
|
+
# @see #wait_for
|
186
|
+
# @see #wait_for_element_exists
|
187
|
+
# @see Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS
|
188
|
+
#
|
189
|
+
# @param [Array<String>] elements_arr an Array of Calabash queries to wait for (i.e. `element_exists(element_query)`)
|
190
|
+
# @param [Hash] options options for controlling the details of the wait.
|
191
|
+
# The same options as {Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS} apply.
|
192
|
+
# @return [nil] when the condition is satisfied
|
193
|
+
# @raise [Calabash::Cucumber::WaitHelpers::WaitError] when the timeout is exceeded
|
98
194
|
def wait_for_elements_exist(elements_arr, options={})
|
99
195
|
if elements_arr.is_a?(String)
|
100
196
|
elements_arr = [elements_arr]
|
101
197
|
end
|
102
|
-
options[:timeout_message] = options[:timeout_message] || "Timeout waiting for elements: #{elements_arr.join(
|
198
|
+
options[:timeout_message] = options[:timeout_message] || "Timeout waiting for elements: #{elements_arr.join(',')}"
|
103
199
|
wait_for(options) do
|
104
200
|
elements_arr.all? { |q| element_exists(q) }
|
105
201
|
end
|
106
202
|
end
|
107
|
-
|
203
|
+
|
204
|
+
# Waits for a Calabash query to return an empty result (typically a UI element to disappear).
|
205
|
+
# Uses `wait_for`.
|
206
|
+
# @see #wait_for
|
207
|
+
# @see #wait_for_element_exists
|
208
|
+
# @see Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS
|
209
|
+
#
|
210
|
+
# @param [String] element_query a Calabash query to be empty (i.e. `element_does_not_exist(element_query)`)
|
211
|
+
# @param [Hash] options options for controlling the details of the wait.
|
212
|
+
# The same options as {Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS} apply.
|
213
|
+
# @return [nil] when the condition is satisfied
|
214
|
+
# @raise [Calabash::Cucumber::WaitHelpers::WaitError] when the timeout is exceeded
|
215
|
+
def wait_for_element_does_not_exists(element_query, options={})
|
216
|
+
options[:timeout_message] = options[:timeout_message] || "Timeout waiting for element to not exist: #{element_query}"
|
217
|
+
wait_for(options) { element_does_not_exist(element_query) }
|
218
|
+
end
|
219
|
+
|
220
|
+
# Waits for one or more Calabash queries to all return empty results (typically a UI elements to disappear).
|
221
|
+
# Uses `wait_for`.
|
222
|
+
# @see #wait_for
|
223
|
+
# @see #wait_for_element_exists
|
224
|
+
# @see #wait_for_element_does_not_exists
|
225
|
+
# @see Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS
|
226
|
+
#
|
227
|
+
# @param [Array<String>] elements_arr an Array of Calabash queries to be empty (i.e. `element_does_not_exist(element_query)`)
|
228
|
+
# @param [Hash] options options for controlling the details of the wait.
|
229
|
+
# The same options as {Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS} apply.
|
230
|
+
# @return [nil] when the condition is satisfied
|
231
|
+
# @raise [Calabash::Cucumber::WaitHelpers::WaitError] when the timeout is exceeded
|
108
232
|
def wait_for_elements_do_not_exist(elements_arr, options={})
|
109
233
|
if elements_arr.is_a?(String)
|
110
234
|
elements_arr = [elements_arr]
|
@@ -115,6 +239,7 @@ module Calabash
|
|
115
239
|
end
|
116
240
|
end
|
117
241
|
|
242
|
+
# @!visibility private
|
118
243
|
def wait_for_condition(options = {})
|
119
244
|
timeout = options[:timeout]
|
120
245
|
unless timeout && timeout > 0
|
@@ -142,13 +267,13 @@ module Calabash
|
|
142
267
|
|
143
268
|
begin
|
144
269
|
Timeout::timeout(timeout+CLIENT_TIMEOUT_ADDITION, WaitError) do
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
270
|
+
res = http({:method => :post, :path => 'condition'},
|
271
|
+
options)
|
272
|
+
res = JSON.parse(res)
|
273
|
+
unless res['outcome'] == 'SUCCESS'
|
274
|
+
raise WaitError.new(res['reason'])
|
275
|
+
end
|
276
|
+
sleep(options[:post_timeout]) if options[:post_timeout] > 0
|
152
277
|
end
|
153
278
|
rescue WaitError => e
|
154
279
|
msg = timeout_message || e
|
@@ -168,75 +293,83 @@ module Calabash
|
|
168
293
|
end
|
169
294
|
end
|
170
295
|
|
296
|
+
# Waits for all elements to stop animating (EXPERIMENTAL).
|
297
|
+
# @param [Hash] options options for controlling the details of the wait.
|
298
|
+
# @option options [Numeric] :timeout (30) maximum time to wait
|
299
|
+
# @return [nil] when the condition is satisfied
|
300
|
+
# @raise [Calabash::Cucumber::WaitHelpers::WaitError] when the timeout is exceeded
|
171
301
|
def wait_for_none_animating(options = {})
|
172
302
|
options[:condition] = CALABASH_CONDITIONS[:none_animating]
|
173
303
|
wait_for_condition(options)
|
174
304
|
end
|
175
305
|
|
306
|
+
# Waits for the status-bar network indicator to stop animating (network activity done).
|
307
|
+
# @param [Hash] options options for controlling the details of the wait.
|
308
|
+
# @option options [Numeric] :timeout (30) maximum time to wait
|
309
|
+
# @return [nil] when the condition is satisfied
|
310
|
+
# @raise [Calabash::Cucumber::WaitHelpers::WaitError] when the timeout is exceeded
|
176
311
|
def wait_for_no_network_indicator(options = {})
|
177
312
|
options[:condition] = CALABASH_CONDITIONS[:no_network_indicator]
|
178
313
|
wait_for_condition(options)
|
179
314
|
end
|
180
315
|
|
181
|
-
#
|
316
|
+
# Combines waiting for elements and waiting for animations.
|
317
|
+
# @param [Array] done_queries Calabash queries to wait for (one or more).
|
318
|
+
# @param [Hash] check_options ({}) options used for `wait_for_elements_exists(done_queries, check_options)`
|
319
|
+
# @param [Hash] animation_options ({}) options used for `wait_for_none_animating(animation_options)`
|
182
320
|
def wait_for_transition(done_queries, check_options={},animation_options={})
|
183
321
|
done_queries = [*done_queries]
|
184
322
|
wait_for_elements_exist(done_queries,check_options)
|
185
323
|
wait_for_none_animating(animation_options)
|
186
324
|
end
|
187
325
|
|
326
|
+
# Combines touching an element and `wait_for_transition`
|
327
|
+
# @see #wait_for_transition
|
328
|
+
# @param [String] touch_q the Calabash query to touch
|
329
|
+
# @param [Array] done_queries passed to `wait_for_transition`
|
330
|
+
# @param [Hash] check_options ({}) passed to `wait_for_transition`
|
331
|
+
# @param [Hash] animation_options ({}) passed to `wait_for_transition`
|
188
332
|
def touch_transition(touch_q, done_queries,check_options={},animation_options={})
|
189
333
|
touch(touch_q)
|
190
334
|
wait_for_transition(done_queries,check_options,animation_options)
|
191
335
|
end
|
192
336
|
|
193
|
-
def handle_error_with_options(ex, timeout_message, screenshot_on_error)
|
194
|
-
msg = (timeout_message || ex)
|
195
|
-
if ex
|
196
|
-
msg = "#{msg} (#{ex.class})"
|
197
|
-
end
|
198
|
-
if screenshot_on_error
|
199
|
-
screenshot_and_raise msg
|
200
|
-
else
|
201
|
-
raise msg
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
def wait_error(msg)
|
206
|
-
(msg.is_a?(String) ? WaitError.new(msg) : msg)
|
207
|
-
end
|
208
|
-
|
209
337
|
# Performs a lambda action until the element (a query string) appears.
|
210
|
-
# The default action is to do nothing.
|
338
|
+
# The default action is to do nothing. Similar to `wait_poll`.
|
339
|
+
#
|
340
|
+
# Raises an error if no uiquery is specified.
|
211
341
|
#
|
212
|
-
#
|
213
|
-
# which are timeout, retry frequency, post_timeout, timeout_message, and
|
214
|
-
# screenshot on error.
|
342
|
+
# @see #wait_poll
|
215
343
|
#
|
216
|
-
#
|
217
|
-
#
|
344
|
+
# @example
|
345
|
+
# until_element_exists("button", :action => lambda { swipe("up") })
|
346
|
+
# @param [String] uiquery the Calabash query to wait for
|
347
|
+
# @param [Hash] opts options for controlling the details of the wait.
|
348
|
+
# The same options as {Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS} apply.
|
218
349
|
def until_element_exists(uiquery, opts = {})
|
219
|
-
extra_opts = { :until_exists => uiquery, :action => lambda {
|
350
|
+
extra_opts = { :until_exists => uiquery, :action => lambda {} }
|
220
351
|
opts = DEFAULT_OPTS.merge(extra_opts).merge(opts)
|
221
|
-
wait_poll(opts) do
|
352
|
+
wait_poll(opts) do
|
222
353
|
opts[:action].call
|
223
354
|
end
|
224
355
|
end
|
225
356
|
|
226
357
|
# Performs a lambda action until the element (a query string) disappears.
|
227
|
-
# The default action is to do nothing.
|
358
|
+
# The default action is to do nothing.
|
228
359
|
#
|
229
|
-
# Raises an error if no uiquery is specified.
|
230
|
-
# which are timeout, retry frequency, post_timeout, timeout_message, and
|
231
|
-
# screenshot on error.
|
360
|
+
# Raises an error if no uiquery is specified.
|
232
361
|
#
|
233
|
-
#
|
234
|
-
#
|
362
|
+
# @example
|
363
|
+
# until_element_does_not_exist("button", :action => lambda { swipe("up") })
|
364
|
+
# @see #wait_poll
|
365
|
+
# @param [String] uiquery the Calabash query to wait for disappearing.
|
366
|
+
# @param [Hash] opts options for controlling the details of the wait.
|
367
|
+
# The same options as {Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS} apply.
|
235
368
|
def until_element_does_not_exist(uiquery, opts = {})
|
236
|
-
condition = lambda {
|
237
|
-
extra_opts = { :until => condition, :action => lambda {
|
369
|
+
condition = lambda {element_does_not_exist(uiquery)}
|
370
|
+
extra_opts = { :until => condition, :action => lambda {} }
|
238
371
|
opts = DEFAULT_OPTS.merge(extra_opts).merge(opts)
|
239
|
-
wait_poll(opts) do
|
372
|
+
wait_poll(opts) do
|
240
373
|
opts[:action].call
|
241
374
|
end
|
242
375
|
end
|
@@ -244,16 +377,63 @@ module Calabash
|
|
244
377
|
# Performs a lambda action once the element exists.
|
245
378
|
# The default behavior is to touch the specified element.
|
246
379
|
#
|
247
|
-
# Raises an error if no uiquery is specified.
|
248
|
-
# which are timeout, retry frequency, post_timeout, timeout_message, and
|
249
|
-
# screenshot on error.
|
380
|
+
# Raises an error if no uiquery is specified.
|
250
381
|
#
|
251
|
-
#
|
382
|
+
# @example
|
383
|
+
# when_element_exists("button", :timeout => 10)
|
384
|
+
# @see #wait_for
|
385
|
+
# @param [String] uiquery the Calabash query to wait for.
|
386
|
+
# @param [Hash] opts options for controlling the details of the wait.
|
387
|
+
# The same options as {Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS} apply.
|
252
388
|
def when_element_exists(uiquery, opts = {})
|
253
|
-
action =
|
254
|
-
|
255
|
-
|
256
|
-
|
389
|
+
action = opts[:action] || lambda { touch(uiquery) }
|
390
|
+
wait_for_element_exists(uiquery, opts)
|
391
|
+
action.call
|
392
|
+
end
|
393
|
+
|
394
|
+
# @!visibility private
|
395
|
+
def screenshot_and_retry(msg, &block)
|
396
|
+
path = screenshot
|
397
|
+
res = yield
|
398
|
+
# Validate after taking screenshot
|
399
|
+
if res
|
400
|
+
FileUtils.rm_f(path)
|
401
|
+
return res
|
402
|
+
else
|
403
|
+
embed(path, 'image/png', msg)
|
404
|
+
raise wait_error(msg)
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
# @!visibility private
|
409
|
+
# raises an error by raising a exception and conditionally takes a
|
410
|
+
# screenshot based on the value of +screenshot_on_error+.
|
411
|
+
# @param [Exception,nil] ex an exception to raise
|
412
|
+
# @param [String,nil] timeout_message the message of the raise
|
413
|
+
# @param [Boolean] screenshot_on_error if true takes a screenshot before
|
414
|
+
# raising an error
|
415
|
+
# @return [nil]
|
416
|
+
# @raise RuntimeError based on +ex+ and +timeout_message+
|
417
|
+
def handle_error_with_options(ex, timeout_message, screenshot_on_error)
|
418
|
+
msg = (timeout_message || ex)
|
419
|
+
if ex
|
420
|
+
msg = "#{msg} (#{ex.class})"
|
421
|
+
end
|
422
|
+
if screenshot_on_error
|
423
|
+
screenshot_and_raise msg
|
424
|
+
else
|
425
|
+
raise msg
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
# @private
|
430
|
+
# if +msg+ is a String, a new WaitError is returned. Otherwise +msg+
|
431
|
+
# itself is returned.
|
432
|
+
# @param [String,Object] msg a message to raise
|
433
|
+
# @return [WaitError] if +msg+ is a String, returns a new WaitError
|
434
|
+
# @return [Object] if +msg+ is anything else, returns +msg+
|
435
|
+
def wait_error(msg)
|
436
|
+
(msg.is_a?(String) ? WaitError.new(msg) : msg)
|
257
437
|
end
|
258
438
|
|
259
439
|
end
|