testa_appium_driver 0.1.0 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.idea/deployment.xml +2 -9
- data/.idea/webServers.xml +1 -1
- data/README.md +365 -52
- data/lib/testa_appium_driver/android/class_selectors.rb +50 -0
- data/lib/testa_appium_driver/android/driver.rb +2 -1
- data/lib/testa_appium_driver/android/locator/attributes.rb +4 -4
- data/lib/testa_appium_driver/android/locator.rb +17 -5
- data/lib/testa_appium_driver/android/selenium_element.rb +1 -1
- data/lib/testa_appium_driver/common/constants.rb +2 -0
- data/lib/testa_appium_driver/common/helpers.rb +26 -28
- data/lib/testa_appium_driver/common/locator/scroll_actions.rb +152 -58
- data/lib/testa_appium_driver/common/locator.rb +58 -10
- data/lib/testa_appium_driver/common/scroll_actions/w3c_scroll_actions.rb +12 -4
- data/lib/testa_appium_driver/common/scroll_actions.rb +36 -33
- data/lib/testa_appium_driver/common/selenium_element.rb +19 -0
- data/lib/testa_appium_driver/driver.rb +41 -41
- data/lib/testa_appium_driver/ios/driver.rb +1 -0
- data/lib/testa_appium_driver/ios/locator/attributes.rb +5 -3
- data/lib/testa_appium_driver/ios/locator.rb +17 -4
- data/lib/testa_appium_driver/version.rb +1 -1
- data/testa_appium_driver.gemspec +41 -40
- data/testa_appium_driver.iml +1 -35
- metadata +11 -8
@@ -29,27 +29,17 @@ module TestaAppiumDriver
|
|
29
29
|
def hash_to_uiautomator(hash, single = true)
|
30
30
|
command = "new UiSelector()"
|
31
31
|
|
32
|
-
|
33
|
-
# shorthand ids like myId make full ids => my.app.package:id/myId
|
34
|
-
|
35
|
-
if hash[:id][0] == "="
|
36
|
-
id = hash[:id][1..-1]
|
37
|
-
else
|
38
|
-
id = "#{@driver.current_package}:id/#{hash[:id]}"
|
39
|
-
end
|
40
|
-
else
|
41
|
-
id = hash[:id]
|
42
|
-
end
|
32
|
+
id = resolve_id(hash[:id])
|
43
33
|
command = "#{ command }.resourceId(\"#{ %(#{ id }) }\")" if id && id.kind_of?(String)
|
44
|
-
command = "#{ command }.resourceIdMatches(\"
|
34
|
+
command = "#{ command }.resourceIdMatches(\".*#{ %(#{ id.source }) }.*\")" if id && id.kind_of?(Regexp)
|
45
35
|
command = "#{ command }.description(\"#{ %(#{ hash[:desc] }) }\")" if hash[:desc] && hash[:desc].kind_of?(String)
|
46
|
-
command = "#{ command }.descriptionMatches(\"
|
36
|
+
command = "#{ command }.descriptionMatches(\".*#{ %(#{ hash[:desc].source }) }.*\")" if hash[:desc] && hash[:desc].kind_of?(Regexp)
|
47
37
|
command = "#{ command }.className(\"#{ %(#{ hash[:class] }) }\")" if hash[:class] && hash[:class].kind_of?(String)
|
48
|
-
command = "#{ command }.classNameMatches(\"
|
38
|
+
command = "#{ command }.classNameMatches(\".*#{ %(#{ hash[:class].source }) }.*\")" if hash[:class] && hash[:class].kind_of?(Regexp)
|
49
39
|
command = "#{ command }.text(\"#{ %(#{ hash[:text] }) }\")" if hash[:text] && hash[:text].kind_of?(String)
|
50
|
-
command = "#{ command }.textMatches(\"
|
40
|
+
command = "#{ command }.textMatches(\".*#{ %(#{ hash[:text].source }) }.*\")" if hash[:text] && hash[:text].kind_of?(Regexp)
|
51
41
|
command = "#{ command }.packageName(\"#{ %(#{ hash[:package] }) }\")" if hash[:package] && hash[:package].kind_of?(String)
|
52
|
-
command = "#{ command }.packageNameMatches(\"
|
42
|
+
command = "#{ command }.packageNameMatches(\".*#{ %(#{ hash[:package].source }) }.*\")" if hash[:package] && hash[:package].kind_of?(Regexp)
|
53
43
|
|
54
44
|
command = "#{ command }.longClickable(#{ hash[:long_clickable] })" if hash[:long_clickable]
|
55
45
|
command = "#{ command }.checkable(#{ hash[:checkable] })" unless hash[:checkable].nil?
|
@@ -99,18 +89,10 @@ module TestaAppiumDriver
|
|
99
89
|
|
100
90
|
command = "//"
|
101
91
|
|
102
|
-
|
103
|
-
# shorthand ids like myId make full ids => my.app.package:id/myId
|
104
|
-
if hash[:id][0] == "="
|
105
|
-
id = hash[:id][1..-1]
|
106
|
-
else
|
107
|
-
id = "#{@driver.current_package}:id/#{hash[:id]}"
|
108
|
-
end
|
109
|
-
else
|
110
|
-
id = hash[:id]
|
111
|
-
end
|
92
|
+
|
112
93
|
|
113
94
|
if for_android
|
95
|
+
id = resolve_id(hash[:id])
|
114
96
|
if hash[:class] && hash[:class].kind_of?(String)
|
115
97
|
command = "#{ command }#{hash[:class] }"
|
116
98
|
elsif hash[:class] && hash[:class].kind_of?(Regexp)
|
@@ -140,6 +122,8 @@ module TestaAppiumDriver
|
|
140
122
|
command = "#{ command }[@selected=\"#{ hash[:selected] }\"]" unless hash[:selected].nil?
|
141
123
|
command = "#{ command }[@scrollable=\"#{ hash[:scrollable] }\"]" unless hash[:scrollable].nil?
|
142
124
|
else
|
125
|
+
|
126
|
+
hash[:type] = hash[:class] unless hash[:class].nil?
|
143
127
|
if hash[:type] && hash[:type].kind_of?(String)
|
144
128
|
command = "#{ command }#{hash[:type] }"
|
145
129
|
elsif hash[:type] && hash[:type].kind_of?(Regexp)
|
@@ -196,7 +180,7 @@ module TestaAppiumDriver
|
|
196
180
|
def extract_selectors_from_params(params = {})
|
197
181
|
selectors = params.select { |key, value| [
|
198
182
|
:id,
|
199
|
-
:
|
183
|
+
:long_clickable,
|
200
184
|
:desc,
|
201
185
|
:class,
|
202
186
|
:text,
|
@@ -220,7 +204,7 @@ module TestaAppiumDriver
|
|
220
204
|
:height,
|
221
205
|
:visible,
|
222
206
|
:name,
|
223
|
-
:value
|
207
|
+
:value,
|
224
208
|
].include?(key) }
|
225
209
|
params = Hash[params.to_a - selectors.to_a]
|
226
210
|
|
@@ -238,5 +222,19 @@ module TestaAppiumDriver
|
|
238
222
|
|
239
223
|
return params, selectors
|
240
224
|
end
|
225
|
+
|
226
|
+
|
227
|
+
def resolve_id(id)
|
228
|
+
if id && id.kind_of?(String) && !id.match?(/.*:id\//)
|
229
|
+
# shorthand ids like myId make full ids => my.app.package:id/myId
|
230
|
+
if id[0] == "="
|
231
|
+
return id[1..-1]
|
232
|
+
else
|
233
|
+
return "#{@driver.current_package}:id/#{id}"
|
234
|
+
end
|
235
|
+
else
|
236
|
+
id
|
237
|
+
end
|
238
|
+
end
|
241
239
|
end
|
242
240
|
end
|
@@ -2,6 +2,7 @@ module TestaAppiumDriver
|
|
2
2
|
#noinspection RubyTooManyMethodsInspection
|
3
3
|
class Locator
|
4
4
|
|
5
|
+
# performs a long tap on the retrieved element
|
5
6
|
# @param [Float] duration in seconds
|
6
7
|
def long_tap(duration = LONG_TAP_DURATION)
|
7
8
|
action_builder = @driver.action
|
@@ -15,169 +16,238 @@ module TestaAppiumDriver
|
|
15
16
|
@driver.perform_actions [f1]
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
|
20
|
+
# scrolls to the start of the scrollable containers and scrolls to the end,
|
21
|
+
# everytime a locator element is found the given block is executed
|
22
|
+
# @return [Array<Selenium::WebDriver::Element>]
|
23
|
+
def each(top: nil, bottom: nil, right: nil, left: nil, direction: nil, &block)
|
24
|
+
deadzone = _process_deadzone(top, bottom, right, left)
|
20
25
|
raise "Each can only be performed on multiple elements locator" if @single
|
21
26
|
deadzone = @scrollable_locator.scroll_deadzone if deadzone.nil? && !@scrollable_locator.nil?
|
22
27
|
sa = ScrollActions.new(@scrollable_locator,
|
23
28
|
locator: self,
|
24
29
|
deadzone: deadzone,
|
25
30
|
default_scroll_strategy: @default_scroll_strategy)
|
26
|
-
|
31
|
+
if direction.nil?
|
32
|
+
sa.each(&block)
|
33
|
+
else
|
34
|
+
sa.send("each_#{direction}", &block)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# scrolls down from the current page view (without prior scrolling to the top) and
|
39
|
+
# everytime a locator element is found the given block is executed
|
40
|
+
# @return [Array<Selenium::WebDriver::Element>]
|
41
|
+
def each_down(top: nil, bottom: nil, right: nil, left: nil, &block)
|
42
|
+
each(top: top, bottom: bottom, right: right, left: left, direction: :down, &block)
|
43
|
+
end
|
44
|
+
|
45
|
+
# scrolls up from the current page view (without prior scrolling to the bottom) and
|
46
|
+
# everytime a locator element is found the given block is executed
|
47
|
+
# @return [Array<Selenium::WebDriver::Element>]
|
48
|
+
def each_up(top: nil, bottom: nil, right: nil, left: nil, &block)
|
49
|
+
each(top: top, bottom: bottom, right: right, left: left, direction: :up, &block)
|
50
|
+
end
|
51
|
+
|
52
|
+
# scrolls right from the current page view (without prior scrolling to the left) and
|
53
|
+
# everytime a locator element is found the given block is executed
|
54
|
+
# @return [Array<Selenium::WebDriver::Element>]
|
55
|
+
def each_right(top: nil, bottom: nil, right: nil, left: nil, &block)
|
56
|
+
each(top: top, bottom: bottom, right: right, left: left, direction: :right, &block)
|
57
|
+
end
|
58
|
+
|
59
|
+
# scrolls left from the current page view (without prior scrolling to the right) and
|
60
|
+
# everytime a locator element is found the given block is executed
|
61
|
+
# @return [Array<Selenium::WebDriver::Element>]
|
62
|
+
def each_left(top: nil, bottom: nil, right: nil, left: nil, &block)
|
63
|
+
each(top: top, bottom: bottom, right: right, left: left, direction: :left, &block)
|
27
64
|
end
|
28
65
|
|
29
66
|
|
30
67
|
# Aligns element (by default) on top of the scrollable container, if the element does not exists it will scroll to find it
|
68
|
+
# The element is aligned if the the distance from the top/bottom/right/left of the scrollable container is less than [TestaAppiumDriver::SCROLL_ALIGNMENT_THRESHOLD]
|
69
|
+
# If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
|
70
|
+
# The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
|
31
71
|
# @return [TestaAppiumDriver::Locator]
|
32
|
-
def align(with = :top,
|
72
|
+
def align(with = :top, top: nil, bottom: nil, right: nil, left: nil, scroll_to_find: false)
|
33
73
|
deadzone = @scrollable_locator.scroll_deadzone if deadzone.nil? && !@scrollable_locator.nil?
|
34
74
|
sa = ScrollActions.new(@scrollable_locator,
|
35
75
|
locator: self,
|
36
76
|
deadzone: deadzone,
|
37
|
-
default_scroll_strategy: @default_scroll_strategy
|
38
|
-
|
39
|
-
sa.align(with)
|
77
|
+
default_scroll_strategy: @default_scroll_strategy)
|
78
|
+
sa.align(with, scroll_to_find)
|
40
79
|
self
|
41
80
|
end
|
42
81
|
|
43
82
|
# Aligns element on top of the scrollable container, if the element does not exists it will scroll to find it
|
83
|
+
# The element is aligned if the the distance from the top of the scrollable container is less than [TestaAppiumDriver::SCROLL_ALIGNMENT_THRESHOLD]
|
84
|
+
# If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
|
85
|
+
# The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
|
44
86
|
# @return [TestaAppiumDriver::Locator]
|
45
|
-
def align_top(
|
46
|
-
align(:top,
|
87
|
+
def align_top(top: nil, bottom: nil, right: nil, left: nil)
|
88
|
+
align(:top, top: top, bottom: bottom, right: right, left: left)
|
47
89
|
end
|
48
90
|
|
49
91
|
# Aligns element on bottom of the scrollable container, if the element does not exists it will scroll to find it
|
92
|
+
# The element is aligned if the the distance from the bottom of the scrollable container is less than [TestaAppiumDriver::SCROLL_ALIGNMENT_THRESHOLD]
|
93
|
+
# If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
|
94
|
+
# The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
|
50
95
|
# @return [TestaAppiumDriver::Locator]
|
51
|
-
def align_bottom(
|
52
|
-
align(:bottom,
|
96
|
+
def align_bottom(top: nil, bottom: nil, right: nil, left: nil)
|
97
|
+
align(:bottom, top: top, bottom: bottom, right: right, left: left)
|
53
98
|
end
|
54
99
|
|
55
100
|
# Aligns element on left of the scrollable container, if the element does not exists it will scroll to find it
|
101
|
+
# The element is aligned if the the distance from the left of the scrollable container is less than [TestaAppiumDriver::SCROLL_ALIGNMENT_THRESHOLD]
|
102
|
+
# If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
|
103
|
+
# The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
|
56
104
|
# @return [TestaAppiumDriver::Locator]
|
57
|
-
def align_left(
|
58
|
-
align(:left,
|
105
|
+
def align_left(top: nil, bottom: nil, right: nil, left: nil)
|
106
|
+
align(:left, top: top, bottom: bottom, right: right, left: left)
|
59
107
|
end
|
60
108
|
|
61
109
|
# Aligns element on right of the scrollable container, if the element does not exists it will scroll to find it
|
110
|
+
# The element is aligned if the the distance from the right of the scrollable container is less than [TestaAppiumDriver::SCROLL_ALIGNMENT_THRESHOLD]
|
111
|
+
# If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
|
112
|
+
# The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
|
62
113
|
# @return [TestaAppiumDriver::Locator]
|
63
|
-
def align_right(
|
64
|
-
align(:right,
|
114
|
+
def align_right(top: nil, bottom: nil, right: nil, left: nil)
|
115
|
+
align(:right, top: top, bottom: bottom, right: right, left: left)
|
65
116
|
end
|
66
117
|
|
67
118
|
# Aligns element (by default) on top of the scrollable container, if the element does not exists it raise an exception
|
119
|
+
# The element is aligned if the the distance from the top/bottom/right/left of the scrollable container is less than [TestaAppiumDriver::SCROLL_ALIGNMENT_THRESHOLD]
|
120
|
+
# If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
|
121
|
+
# The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
|
68
122
|
# @return [TestaAppiumDriver::Locator]
|
69
|
-
def align!(with = :top,
|
70
|
-
align(with,
|
123
|
+
def align!(with = :top, top: nil, bottom: nil, right: nil, left: nil)
|
124
|
+
align(with, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true)
|
71
125
|
end
|
72
126
|
|
73
127
|
# Aligns element on top of the scrollable container, if the element does not exists it raise an exception
|
128
|
+
# The element is aligned if the the distance from the top of the scrollable container is less than [TestaAppiumDriver::SCROLL_ALIGNMENT_THRESHOLD]
|
129
|
+
# If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
|
130
|
+
# The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
|
74
131
|
# @return [TestaAppiumDriver::Locator]
|
75
|
-
def align_top!(
|
76
|
-
align(:top,
|
132
|
+
def align_top!(top: nil, bottom: nil, right: nil, left: nil)
|
133
|
+
align(:top, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true)
|
77
134
|
end
|
78
135
|
|
79
136
|
# Aligns element on bottom of the scrollable container, if the element does not exists it raise an exception
|
137
|
+
# The element is aligned if the the distance from the bottom of the scrollable container is less than [TestaAppiumDriver::SCROLL_ALIGNMENT_THRESHOLD]
|
138
|
+
# If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
|
139
|
+
# The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
|
80
140
|
# @return [TestaAppiumDriver::Locator]
|
81
|
-
def align_bottom!(
|
82
|
-
align(:bottom,
|
141
|
+
def align_bottom!(top: nil, bottom: nil, right: nil, left: nil)
|
142
|
+
align(:bottom, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true)
|
83
143
|
end
|
84
144
|
|
85
145
|
# Aligns element on left of the scrollable container, if the element does not exists it raise an exception
|
146
|
+
# The element is aligned if the the distance from the left of the scrollable container is less than [TestaAppiumDriver::SCROLL_ALIGNMENT_THRESHOLD]
|
147
|
+
# If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
|
148
|
+
# The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
|
86
149
|
# @return [TestaAppiumDriver::Locator]
|
87
|
-
def align_left!(
|
88
|
-
align(:left,
|
150
|
+
def align_left!(top: nil, bottom: nil, right: nil, left: nil)
|
151
|
+
align(:left, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true)
|
89
152
|
end
|
90
153
|
|
91
154
|
# Aligns element on right of the scrollable container, if the element does not exists it raise an exception
|
155
|
+
# The element is aligned if the the distance from the right of the scrollable container is less than [TestaAppiumDriver::SCROLL_ALIGNMENT_THRESHOLD]
|
156
|
+
# If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
|
157
|
+
# The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
|
92
158
|
# @return [TestaAppiumDriver::Locator]
|
93
|
-
def align_right!(
|
94
|
-
align(:right,
|
159
|
+
def align_right!(top: nil, bottom: nil, right: nil, left: nil)
|
160
|
+
align(:right, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true)
|
95
161
|
end
|
96
162
|
|
97
163
|
|
98
164
|
# First scrolls to the beginning of the scrollable container and then scrolls down until element is found or end is reached
|
99
165
|
# @return [TestaAppiumDriver::Locator]
|
100
|
-
def scroll_to(
|
101
|
-
|
166
|
+
def scroll_to(top: nil, bottom: nil, right: nil, left: nil, max_scrolls: nil, direction: nil)
|
167
|
+
if direction
|
168
|
+
_scroll_dir_to(_process_deadzone(top, bottom, right, left), max_scrolls, direction)
|
169
|
+
else
|
170
|
+
_scroll_to(_process_deadzone(top, bottom, right, left), max_scrolls)
|
171
|
+
end
|
102
172
|
end
|
103
173
|
|
104
174
|
|
105
175
|
# Scrolls down until element is found or end is reached
|
106
176
|
# @return [TestaAppiumDriver::Locator]
|
107
|
-
def scroll_down_to(
|
108
|
-
|
177
|
+
def scroll_down_to(top: nil, bottom: nil, right: nil, left: nil, max_scrolls: nil)
|
178
|
+
_scroll_dir_to(_process_deadzone(top, bottom, right, left), max_scrolls, :down)
|
109
179
|
end
|
110
180
|
|
111
181
|
# Scrolls up until element is found or end is reached
|
112
182
|
# @return [TestaAppiumDriver::Locator]
|
113
|
-
def scroll_up_to(
|
114
|
-
|
183
|
+
def scroll_up_to(top: nil, bottom: nil, right: nil, left: nil, max_scrolls: nil)
|
184
|
+
_scroll_dir_to(_process_deadzone(top, bottom, right, left), max_scrolls, :up)
|
115
185
|
end
|
116
186
|
|
117
187
|
# Scrolls right until element is found or end is reached
|
118
188
|
# @return [TestaAppiumDriver::Locator]
|
119
|
-
def scroll_right_to(
|
120
|
-
|
189
|
+
def scroll_right_to(top: nil, bottom: nil, right: nil, left: nil, max_scrolls: nil)
|
190
|
+
_scroll_dir_to(_process_deadzone(top, bottom, right, left), max_scrolls, :right)
|
121
191
|
end
|
122
192
|
|
123
193
|
|
124
194
|
# Scrolls left until element is found or end is reached
|
125
195
|
# @return [TestaAppiumDriver::Locator]
|
126
|
-
def scroll_left_to(
|
127
|
-
|
196
|
+
def scroll_left_to(top: nil, bottom: nil, right: nil, left: nil, max_scrolls: nil)
|
197
|
+
_scroll_dir_to(_process_deadzone(top, bottom, right, left), max_scrolls, :left)
|
128
198
|
end
|
129
199
|
|
130
200
|
# Scrolls to the start of the scrollable container (top on vertical container, left on horizontal)
|
131
201
|
# @return [TestaAppiumDriver::Locator]
|
132
|
-
def scroll_to_start(
|
133
|
-
_scroll_to_start_or_end(:start,
|
202
|
+
def scroll_to_start(top: nil, bottom: nil, right: nil, left: nil)
|
203
|
+
_scroll_to_start_or_end(:start, _process_deadzone(top, bottom, right, left))
|
134
204
|
end
|
135
205
|
|
136
206
|
# Scrolls to the end of the scrollable container (bottom on vertical container, right on horizontal)
|
137
207
|
# @return [TestaAppiumDriver::Locator]
|
138
|
-
def scroll_to_end(
|
139
|
-
_scroll_to_start_or_end(:end,
|
208
|
+
def scroll_to_end(top: nil, bottom: nil, right: nil, left: nil)
|
209
|
+
_scroll_to_start_or_end(:end, _process_deadzone(top, bottom, right, left))
|
140
210
|
end
|
141
211
|
|
142
212
|
|
143
213
|
# @return [TestaAppiumDriver::Locator]
|
144
|
-
def page_down(
|
145
|
-
_page(:down,
|
214
|
+
def page_down(top: nil, bottom: nil, right: nil, left: nil)
|
215
|
+
_page(:down, _process_deadzone(top, bottom, right, left))
|
146
216
|
end
|
147
217
|
|
148
218
|
# @return [TestaAppiumDriver::Locator]
|
149
|
-
def page_up(
|
150
|
-
_page(:up,
|
219
|
+
def page_up(top: nil, bottom: nil, right: nil, left: nil)
|
220
|
+
_page(:up, _process_deadzone(top, bottom, right, left))
|
151
221
|
end
|
152
222
|
|
153
223
|
# @return [TestaAppiumDriver::Locator]
|
154
|
-
def page_left(
|
155
|
-
_page(:left,
|
224
|
+
def page_left(top: nil, bottom: nil, right: nil, left: nil)
|
225
|
+
_page(:left, _process_deadzone(top, bottom, right, left))
|
156
226
|
end
|
157
227
|
|
158
228
|
# @return [TestaAppiumDriver::Locator]
|
159
|
-
def page_right(
|
160
|
-
_page(:right,
|
229
|
+
def page_right(top: nil, bottom: nil, right: nil, left: nil)
|
230
|
+
_page(:right, _process_deadzone(top, bottom, right, left))
|
161
231
|
end
|
162
232
|
|
163
233
|
# @return [TestaAppiumDriver::Locator]
|
164
|
-
def fling_down(
|
165
|
-
_fling(:down,
|
234
|
+
def fling_down(top: nil, bottom: nil, right: nil, left: nil)
|
235
|
+
_fling(:down, _process_deadzone(top, bottom, right, left))
|
166
236
|
end
|
167
237
|
|
168
238
|
# @return [TestaAppiumDriver::Locator]
|
169
|
-
def fling_up(
|
170
|
-
_fling(:up,
|
239
|
+
def fling_up(top: nil, bottom: nil, right: nil, left: nil)
|
240
|
+
_fling(:up, _process_deadzone(top, bottom, right, left))
|
171
241
|
end
|
172
242
|
|
173
243
|
# @return [TestaAppiumDriver::Locator]
|
174
|
-
def fling_left(
|
175
|
-
_fling(:left,
|
244
|
+
def fling_left(top: nil, bottom: nil, right: nil, left: nil)
|
245
|
+
_fling(:left, _process_deadzone(top, bottom, right, left))
|
176
246
|
end
|
177
247
|
|
178
248
|
# @return [TestaAppiumDriver::Locator]
|
179
|
-
def fling_right(
|
180
|
-
_fling(:right,
|
249
|
+
def fling_right(top: nil, bottom: nil, right: nil, left: nil)
|
250
|
+
_fling(:right, _process_deadzone(top, bottom, right, left))
|
181
251
|
end
|
182
252
|
|
183
253
|
|
@@ -228,6 +298,18 @@ module TestaAppiumDriver
|
|
228
298
|
|
229
299
|
|
230
300
|
private
|
301
|
+
def _process_deadzone(top, bottom, right, left)
|
302
|
+
deadzone = nil
|
303
|
+
if !top.nil? || !bottom.nil? || !right.nil? || !left.nil?
|
304
|
+
deadzone = {}
|
305
|
+
deadzone[:top] = top unless top.nil?
|
306
|
+
deadzone[:bottom] = bottom unless bottom.nil?
|
307
|
+
deadzone[:right] = right unless right.nil?
|
308
|
+
deadzone[:left] = left unless left.nil?
|
309
|
+
end
|
310
|
+
deadzone
|
311
|
+
end
|
312
|
+
|
231
313
|
def _drag_to(x, y)
|
232
314
|
sa = ScrollActions.new(@scrollable_locator,
|
233
315
|
locator: self,
|
@@ -235,6 +317,8 @@ module TestaAppiumDriver
|
|
235
317
|
sa.drag_to(x, y)
|
236
318
|
self
|
237
319
|
end
|
320
|
+
|
321
|
+
|
238
322
|
def _page(direction, deadzone)
|
239
323
|
deadzone = @scrollable_locator.scroll_deadzone if deadzone.nil? && !@scrollable_locator.nil?
|
240
324
|
sa = ScrollActions.new(@scrollable_locator,
|
@@ -262,7 +346,6 @@ module TestaAppiumDriver
|
|
262
346
|
sa = ScrollActions.new(@scrollable_locator,
|
263
347
|
locator: self,
|
264
348
|
deadzone: deadzone,
|
265
|
-
direction: :left,
|
266
349
|
default_scroll_strategy: @default_scroll_strategy)
|
267
350
|
if type == :start
|
268
351
|
sa.scroll_to_start
|
@@ -272,16 +355,27 @@ module TestaAppiumDriver
|
|
272
355
|
self
|
273
356
|
end
|
274
357
|
|
275
|
-
def _scroll_to(deadzone, max_scrolls
|
358
|
+
def _scroll_to(deadzone, max_scrolls)
|
276
359
|
deadzone = @scrollable_locator.scroll_deadzone if deadzone.nil? && !@scrollable_locator.nil?
|
277
360
|
sa = ScrollActions.new(@scrollable_locator,
|
278
361
|
locator: self,
|
279
362
|
deadzone: deadzone,
|
280
363
|
max_scrolls: max_scrolls,
|
281
|
-
direction: direction,
|
282
364
|
default_scroll_strategy: @default_scroll_strategy)
|
283
365
|
sa.scroll_to
|
284
366
|
self
|
285
367
|
end
|
368
|
+
|
369
|
+
def _scroll_dir_to(deadzone, max_scrolls, direction)
|
370
|
+
deadzone = @scrollable_locator.scroll_deadzone if deadzone.nil? && !@scrollable_locator.nil?
|
371
|
+
sa = ScrollActions.new(@scrollable_locator,
|
372
|
+
locator: self,
|
373
|
+
deadzone: deadzone,
|
374
|
+
max_scrolls: max_scrolls,
|
375
|
+
default_scroll_strategy: @default_scroll_strategy)
|
376
|
+
|
377
|
+
sa.send("scroll_#{direction}_to")
|
378
|
+
self
|
379
|
+
end
|
286
380
|
end
|
287
381
|
end
|