testa_appium_driver 0.1.14 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +0 -0
- data/.gitignore +2 -1
- data/.rubocop.yml +5 -13
- data/Gemfile.lock +9 -7
- data/appium-driver.iml +4 -2
- data/lib/testa_appium_driver/common/locator.rb +46 -75
- data/lib/testa_appium_driver/common/scroll_actions/w3c_scroll_actions.rb +1 -1
- data/lib/testa_appium_driver/common/scroll_actions.rb +17 -4
- data/lib/testa_appium_driver/driver.rb +8 -1
- data/lib/testa_appium_driver/ios/selenium_element.rb +1 -0
- data/lib/testa_appium_driver/version.rb +1 -1
- data/testa_appium_driver.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20c9a54ccf31dc2175741de356bde61db83927ad64f71f6b818e0deaffcf2c11
|
4
|
+
data.tar.gz: ea7352197d3dcde42ed2b67403f287382b3acfd89424b19857143ebf0c9f665f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e6ecb34292fffa478a1389d7626a7728fcbd2ebe592cfcc20d59ae487f3eb6c910872cb960d3d6bfa78c2d0e615c694847f8ae65a24ff0379fa3e99e3313bc3
|
7
|
+
data.tar.gz: 5f11da7dbf7b188a88b4cae6738437a06846e7fcb7b4c0bf8396a123317d4363d5a2f0b3cb126194543f5239f056401e5c0ba0b552d3580db19b46f1bdad46f8
|
data/.gitattributes
CHANGED
File without changes
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,13 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
EnforcedStyle: double_quotes
|
7
|
-
|
8
|
-
Style/StringLiteralsInInterpolation:
|
9
|
-
Enabled: true
|
10
|
-
EnforcedStyle: double_quotes
|
11
|
-
|
12
|
-
Layout/LineLength:
|
13
|
-
Max: 120
|
1
|
+
# we have to have per project rubcop files (IDE limitation),
|
2
|
+
# but we want only one config across all projects
|
3
|
+
# you can override any global cops here, in this file
|
4
|
+
inherit_from:
|
5
|
+
- ../.rubocop.yml
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
testa_appium_driver (0.1.
|
5
|
-
appium_lib_core (
|
4
|
+
testa_appium_driver (0.1.17)
|
5
|
+
appium_lib_core (<= 5.4.0)
|
6
6
|
json (~> 2.3)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
appium_lib_core (5.
|
11
|
+
appium_lib_core (5.2.2)
|
12
12
|
faye-websocket (~> 0.11.0)
|
13
|
-
selenium-webdriver (~> 4.
|
13
|
+
selenium-webdriver (~> 4.2, < 4.4)
|
14
14
|
ast (2.4.2)
|
15
15
|
childprocess (4.1.0)
|
16
16
|
diff-lcs (1.5.0)
|
@@ -52,11 +52,13 @@ GEM
|
|
52
52
|
parser (>= 3.1.1.0)
|
53
53
|
ruby-progressbar (1.11.0)
|
54
54
|
rubyzip (2.3.2)
|
55
|
-
selenium-webdriver (4.
|
55
|
+
selenium-webdriver (4.3.0)
|
56
56
|
childprocess (>= 0.5, < 5.0)
|
57
57
|
rexml (~> 3.2, >= 3.2.5)
|
58
|
-
rubyzip (>= 1.2.2)
|
58
|
+
rubyzip (>= 1.2.2, < 3.0)
|
59
|
+
websocket (~> 1.0)
|
59
60
|
unicode-display_width (2.1.0)
|
61
|
+
websocket (1.2.9)
|
60
62
|
websocket-driver (0.7.5)
|
61
63
|
websocket-extensions (>= 0.1.0)
|
62
64
|
websocket-extensions (0.1.5)
|
@@ -71,4 +73,4 @@ DEPENDENCIES
|
|
71
73
|
testa_appium_driver!
|
72
74
|
|
73
75
|
BUNDLED WITH
|
74
|
-
2.
|
76
|
+
2.3.14
|
data/appium-driver.iml
CHANGED
@@ -8,8 +8,9 @@
|
|
8
8
|
</content>
|
9
9
|
<orderEntry type="jdk" jdkName="RVM: ruby-2.7.6" jdkType="RUBY_SDK" />
|
10
10
|
<orderEntry type="sourceFolder" forTests="false" />
|
11
|
-
<orderEntry type="library" scope="PROVIDED" name="appium_lib_core (v5.
|
11
|
+
<orderEntry type="library" scope="PROVIDED" name="appium_lib_core (v5.2.2, RVM: ruby-2.7.6) [gem]" level="application" />
|
12
12
|
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-2.7.6) [gem]" level="application" />
|
13
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.3.14, RVM: ruby-2.7.6) [gem]" level="application" />
|
13
14
|
<orderEntry type="library" scope="PROVIDED" name="childprocess (v4.1.0, RVM: ruby-2.7.6) [gem]" level="application" />
|
14
15
|
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, RVM: ruby-2.7.6) [gem]" level="application" />
|
15
16
|
<orderEntry type="library" scope="PROVIDED" name="eventmachine (v1.2.7, RVM: ruby-2.7.6) [gem]" level="application" />
|
@@ -30,8 +31,9 @@
|
|
30
31
|
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.18.0, RVM: ruby-2.7.6) [gem]" level="application" />
|
31
32
|
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, RVM: ruby-2.7.6) [gem]" level="application" />
|
32
33
|
<orderEntry type="library" scope="PROVIDED" name="rubyzip (v2.3.2, RVM: ruby-2.7.6) [gem]" level="application" />
|
33
|
-
<orderEntry type="library" scope="PROVIDED" name="selenium-webdriver (v4.
|
34
|
+
<orderEntry type="library" scope="PROVIDED" name="selenium-webdriver (v4.3.0, RVM: ruby-2.7.6) [gem]" level="application" />
|
34
35
|
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, RVM: ruby-2.7.6) [gem]" level="application" />
|
36
|
+
<orderEntry type="library" scope="PROVIDED" name="websocket (v1.2.9, RVM: ruby-2.7.6) [gem]" level="application" />
|
35
37
|
<orderEntry type="library" scope="PROVIDED" name="websocket-driver (v0.7.5, RVM: ruby-2.7.6) [gem]" level="application" />
|
36
38
|
<orderEntry type="library" scope="PROVIDED" name="websocket-extensions (v0.1.5, RVM: ruby-2.7.6) [gem]" level="application" />
|
37
39
|
</component>
|
@@ -1,12 +1,10 @@
|
|
1
1
|
require_relative 'locator/scroll_actions'
|
2
2
|
|
3
|
-
|
4
|
-
module TestaAppiumDriver
|
3
|
+
module ::TestaAppiumDriver
|
5
4
|
#noinspection RubyTooManyInstanceVariablesInspection,RubyTooManyMethodsInspection
|
6
5
|
class Locator
|
7
6
|
include Helpers
|
8
7
|
|
9
|
-
|
10
8
|
attr_accessor :xpath_selector
|
11
9
|
attr_accessor :single
|
12
10
|
|
@@ -30,7 +28,6 @@ module TestaAppiumDriver
|
|
30
28
|
|
31
29
|
attr_accessor :index_for_multiple
|
32
30
|
|
33
|
-
|
34
31
|
# locator parameters are:
|
35
32
|
# single: true or false
|
36
33
|
# scrollable_locator: [TestaAppiumDriver::Locator, nil] for scrolling if needed later
|
@@ -67,12 +64,10 @@ module TestaAppiumDriver
|
|
67
64
|
@xpath_selector = hash_to_xpath(@driver.device, selectors, single)
|
68
65
|
end
|
69
66
|
|
70
|
-
|
71
67
|
@from_element = from_element
|
72
68
|
@default_find_strategy = params[:default_find_strategy]
|
73
69
|
@default_scroll_strategy = params[:default_scroll_strategy]
|
74
70
|
|
75
|
-
|
76
71
|
@can_use_id_strategy = is_only_id_selector?(selectors)
|
77
72
|
if @can_use_id_strategy
|
78
73
|
if @driver.device == :android
|
@@ -82,7 +77,6 @@ module TestaAppiumDriver
|
|
82
77
|
end
|
83
78
|
end
|
84
79
|
|
85
|
-
|
86
80
|
@strategy = params[:strategy]
|
87
81
|
@strategy_reason = params[:strategy_reason]
|
88
82
|
|
@@ -91,9 +85,6 @@ module TestaAppiumDriver
|
|
91
85
|
init(params, selectors, single)
|
92
86
|
end
|
93
87
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
88
|
def is_only_id_selector?(selectors)
|
98
89
|
# since, name and id is the same thing for iOS,
|
99
90
|
if @driver.device == :android
|
@@ -104,7 +95,6 @@ module TestaAppiumDriver
|
|
104
95
|
end
|
105
96
|
end
|
106
97
|
|
107
|
-
|
108
98
|
# method missing is used to fetch the element before executing additional commands like click, send_key, count
|
109
99
|
def method_missing(method, *args, &block)
|
110
100
|
r = execute.send(method, *args, &block)
|
@@ -112,7 +102,6 @@ module TestaAppiumDriver
|
|
112
102
|
r
|
113
103
|
end
|
114
104
|
|
115
|
-
|
116
105
|
# @param [Boolean] skip_cache if true it will skip cache check and store
|
117
106
|
# @param [Selenium::WebDriver::Element] force_cache_element, for internal use where we have already the element, and want to execute custom locator methods on it
|
118
107
|
# @return [Selenium::WebDriver::Element, Array]
|
@@ -129,11 +118,6 @@ module TestaAppiumDriver
|
|
129
118
|
return @from_element
|
130
119
|
end
|
131
120
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
121
|
r = @driver.execute(@from_element, @single, strategies_and_selectors, skip_cache: skip_cache, ignore_implicit_wait: ignore_implicit_wait)
|
138
122
|
r = r[@index_for_multiple] if !@index_for_multiple.nil? && !@single
|
139
123
|
r
|
@@ -150,30 +134,28 @@ module TestaAppiumDriver
|
|
150
134
|
if found
|
151
135
|
if block_given? # block is given
|
152
136
|
block.call(self) # use call to execute the block
|
153
|
-
else
|
137
|
+
else
|
138
|
+
# the value of block_argument becomes nil if you didn't give a block
|
154
139
|
# block was not given
|
155
140
|
end
|
156
141
|
end
|
157
142
|
self
|
158
143
|
end
|
159
144
|
|
160
|
-
|
161
145
|
# @param [Integer] timeout in seconds
|
162
146
|
# @return [TestaAppiumDriver::Locator]
|
163
147
|
def wait_until_exists(timeout = nil)
|
164
|
-
args = {timeout: timeout}
|
148
|
+
args = { timeout: timeout }
|
165
149
|
_wait(:until, args)
|
166
150
|
end
|
167
151
|
|
168
|
-
|
169
152
|
# @param [Integer] timeout in seconds
|
170
153
|
# @return [TestaAppiumDriver::Locator]
|
171
154
|
def wait_while_exists(timeout = nil)
|
172
|
-
args = {timeout: timeout}
|
155
|
+
args = { timeout: timeout }
|
173
156
|
_wait(:while, args)
|
174
157
|
end
|
175
158
|
|
176
|
-
|
177
159
|
def wait_while(timeout = nil, args = {})
|
178
160
|
args[:timeout] = timeout
|
179
161
|
_wait(:while, args)
|
@@ -184,13 +166,13 @@ module TestaAppiumDriver
|
|
184
166
|
_wait(:until, args)
|
185
167
|
end
|
186
168
|
|
187
|
-
|
188
169
|
# all timeouts are disabled before check, and enabled after check
|
189
170
|
# @return [boolean] true if it exists in the page regardless if visible or not
|
190
171
|
def exists?
|
191
172
|
found = true
|
192
173
|
begin
|
193
|
-
execute(skip_cache: true, ignore_implicit_wait: true)
|
174
|
+
r = execute(skip_cache: true, ignore_implicit_wait: true)
|
175
|
+
return r.count.positive? if r.is_a?(Array)
|
194
176
|
rescue StandardError
|
195
177
|
found = false
|
196
178
|
end
|
@@ -236,7 +218,7 @@ module TestaAppiumDriver
|
|
236
218
|
else
|
237
219
|
from_element = self.dup
|
238
220
|
from_element.index_for_multiple = instance
|
239
|
-
params = {}.merge({single: true, scrollable_locator: @scrollable_locator})
|
221
|
+
params = {}.merge({ single: true, scrollable_locator: @scrollable_locator })
|
240
222
|
#params[:strategy] = FIND_STRATEGY_XPATH
|
241
223
|
#params[:strategy_reason] = "retrieved instance of a array"
|
242
224
|
params[:default_find_strategy] = @default_find_strategy
|
@@ -245,33 +227,32 @@ module TestaAppiumDriver
|
|
245
227
|
end
|
246
228
|
end
|
247
229
|
|
248
|
-
|
249
230
|
# @param [TestaAppiumDriver::Locator, Selenium::WebDriver::Element, Array] other
|
250
231
|
#noinspection RubyNilAnalysis,RubyUnnecessaryReturnStatement
|
251
232
|
def ==(other)
|
252
233
|
elements = execute
|
253
|
-
other = other.execute if other.
|
234
|
+
other = other.execute if other.is_a?(TestaAppiumDriver::Locator)
|
254
235
|
|
255
|
-
if elements.
|
256
|
-
return false unless other.
|
236
|
+
if elements.is_a?(Array)
|
237
|
+
return false unless other.is_a?(Array)
|
257
238
|
return false if other.count != elements.count
|
258
239
|
return (elements - other).empty?
|
259
240
|
else
|
260
|
-
return false if other.
|
241
|
+
return false if other.is_a?(Array)
|
261
242
|
return elements == other
|
262
243
|
end
|
263
244
|
end
|
264
245
|
|
265
246
|
def as_json
|
266
247
|
{
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
248
|
+
strategy: @strategy,
|
249
|
+
default_strategy: @default_find_strategy,
|
250
|
+
single: @single,
|
251
|
+
uiautomator: defined?(self.ui_selector) ? ui_selector : nil,
|
252
|
+
xpath: @xpath_selector,
|
253
|
+
scroll_orientation: @scroll_orientation,
|
254
|
+
resolved: strategies_and_selectors,
|
255
|
+
index_for_multiple: @index_for_multiple
|
275
256
|
}
|
276
257
|
end
|
277
258
|
|
@@ -283,7 +264,6 @@ module TestaAppiumDriver
|
|
283
264
|
[self.to_s]
|
284
265
|
end
|
285
266
|
|
286
|
-
|
287
267
|
# @return [TestaAppiumDriver::Locator]
|
288
268
|
def as_scrollable(orientation: :vertical, top: nil, bottom: nil, right: nil, left: nil)
|
289
269
|
@scroll_orientation = orientation
|
@@ -298,47 +278,48 @@ module TestaAppiumDriver
|
|
298
278
|
self
|
299
279
|
end
|
300
280
|
|
301
|
-
|
302
281
|
def first_and_last_leaf
|
303
282
|
@driver.first_and_last_leaf(execute)
|
304
283
|
end
|
305
284
|
|
306
|
-
def
|
307
|
-
|
285
|
+
def first_and_last_child
|
286
|
+
@driver.first_and_last_child(execute)
|
308
287
|
end
|
309
288
|
|
310
|
-
|
289
|
+
def double_click(x = nil, y = nil)
|
290
|
+
click(x, y, double: true)
|
291
|
+
end
|
311
292
|
|
312
293
|
# if both x or y, or both are not given, will click in the center of the element
|
313
294
|
# @param x If positive integer, will offset the click from the left side, if negative integer, will offset the click from the right. If float value is given, it will threat it as percentage offset, giving it 0.5 will click in the middle
|
314
295
|
# @param y If positive integer, will offset the click from the bottom side, if negative integer, will offset the click from the top. If float value is given, it will threat it as percentage offset, giving it 0.5 will click in the middle
|
315
|
-
def click(x = nil, y = nil, double: false)
|
316
|
-
if !x.nil? && !y.nil? || double
|
296
|
+
def click(x = nil, y = nil, double: false, by_coords: false)
|
297
|
+
if !x.nil? && !y.nil? || double || by_coords
|
317
298
|
|
318
|
-
x=0.5 if x.nil?
|
319
|
-
y=0.5 if y.nil?
|
299
|
+
x = 0.5 if x.nil?
|
300
|
+
y = 0.5 if y.nil?
|
320
301
|
|
321
302
|
b = self.bounds
|
322
|
-
if x.
|
303
|
+
if x.is_a?(Integer)
|
323
304
|
if x >= 0
|
324
305
|
x = b.top_left.x + x
|
325
306
|
else
|
326
307
|
x = b.bottom_right.x + x
|
327
308
|
end
|
328
|
-
elsif x.
|
329
|
-
x = b.top_left.x + b.width*x
|
309
|
+
elsif x.is_a?(Float) && x <= 1.0 && x >= 0
|
310
|
+
x = b.top_left.x + b.width * x
|
330
311
|
else
|
331
312
|
raise "x value #{x} not supported. Use integer as pixel or float (0..1) as percentage of element width"
|
332
313
|
end
|
333
314
|
|
334
|
-
if y.
|
315
|
+
if y.is_a?(Integer)
|
335
316
|
if y >= 0
|
336
317
|
y = b.top_left.y + y
|
337
318
|
else
|
338
319
|
y = b.bottom_right + y
|
339
320
|
end
|
340
|
-
elsif y.
|
341
|
-
y = b.top_left.y + b.height*y
|
321
|
+
elsif y.is_a?(Float) && y <= 1.0 && y >= 0
|
322
|
+
y = b.top_left.y + b.height * y
|
342
323
|
else
|
343
324
|
raise "y value #{x} not supported. Use integer as pixel or float (0..1) as percentage of element height"
|
344
325
|
end
|
@@ -360,18 +341,16 @@ module TestaAppiumDriver
|
|
360
341
|
else
|
361
342
|
# on ios, if element is not visible, first click will scroll to it
|
362
343
|
# then on second click actually perform the click
|
363
|
-
visible = visible?
|
344
|
+
#visible = visible?
|
364
345
|
perform_driver_method(:click)
|
365
|
-
perform_driver_method(:click) unless visible rescue nil
|
346
|
+
#perform_driver_method(:click) unless visible rescue nil
|
366
347
|
end
|
367
348
|
end
|
368
349
|
end
|
369
350
|
|
370
|
-
|
371
351
|
alias_method :tap, :click
|
372
352
|
alias_method :double_tap, :double_click
|
373
353
|
|
374
|
-
|
375
354
|
def send_key(*args)
|
376
355
|
perform_driver_method(:send_keys, *args)
|
377
356
|
end
|
@@ -380,12 +359,11 @@ module TestaAppiumDriver
|
|
380
359
|
perform_driver_method(:clear)
|
381
360
|
end
|
382
361
|
|
383
|
-
|
384
362
|
# Return parent element
|
385
363
|
# @return [TestaAppiumDriver::Locator]
|
386
364
|
def parent
|
387
365
|
raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "parent") if @strategy != FIND_STRATEGY_XPATH && !@strategy.nil?
|
388
|
-
raise "Cannot add parent selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]")
|
366
|
+
raise "Cannot add parent selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]") && !@from_element.nil?
|
389
367
|
|
390
368
|
locator = self.dup
|
391
369
|
locator.strategy = FIND_STRATEGY_XPATH
|
@@ -399,7 +377,7 @@ module TestaAppiumDriver
|
|
399
377
|
# @return [TestaAppiumDriver::Locator]
|
400
378
|
def children
|
401
379
|
raise "Cannot add children selector to array" unless @single
|
402
|
-
raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "children") if @strategy != FIND_STRATEGY_XPATH &&
|
380
|
+
raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "children") if @strategy != FIND_STRATEGY_XPATH && @strategy != FIND_STRATEGY_CLASS_CHAIN && !@strategy.nil?
|
403
381
|
|
404
382
|
locator = self.dup
|
405
383
|
locator.strategy_reason = "children"
|
@@ -416,7 +394,6 @@ module TestaAppiumDriver
|
|
416
394
|
locator
|
417
395
|
end
|
418
396
|
|
419
|
-
|
420
397
|
# Return first child element
|
421
398
|
# @return [TestaAppiumDriver::Locator]
|
422
399
|
def child
|
@@ -438,12 +415,11 @@ module TestaAppiumDriver
|
|
438
415
|
locator
|
439
416
|
end
|
440
417
|
|
441
|
-
|
442
418
|
# @return [TestaAppiumDriver::Locator]
|
443
419
|
def siblings
|
444
420
|
raise "Cannot add siblings selector to array" unless @single
|
445
421
|
raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "siblings") if @strategy != FIND_STRATEGY_XPATH && !@strategy.nil?
|
446
|
-
raise "Cannot add siblings selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]")
|
422
|
+
raise "Cannot add siblings selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]") && !@from_element.nil?
|
447
423
|
|
448
424
|
locator = self.dup
|
449
425
|
locator.strategy = FIND_STRATEGY_XPATH
|
@@ -459,7 +435,7 @@ module TestaAppiumDriver
|
|
459
435
|
def preceding_siblings
|
460
436
|
raise "Cannot add preceding_siblings selector to array" unless @single
|
461
437
|
raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "preceding_siblings") if @strategy != FIND_STRATEGY_XPATH && !@strategy.nil?
|
462
|
-
raise "Cannot add preceding_siblings selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]")
|
438
|
+
raise "Cannot add preceding_siblings selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]") && !@from_element.nil?
|
463
439
|
|
464
440
|
locator = self.dup
|
465
441
|
locator.strategy = FIND_STRATEGY_XPATH
|
@@ -475,7 +451,7 @@ module TestaAppiumDriver
|
|
475
451
|
def preceding_sibling
|
476
452
|
raise "Cannot add preceding_sibling selector to array" unless @single
|
477
453
|
raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "preceding_sibling") if @strategy != FIND_STRATEGY_XPATH && !@strategy.nil?
|
478
|
-
raise "Cannot add preceding siblings selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]")
|
454
|
+
raise "Cannot add preceding siblings selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]") && !@from_element.nil?
|
479
455
|
|
480
456
|
locator = self.dup
|
481
457
|
locator.strategy = FIND_STRATEGY_XPATH
|
@@ -489,12 +465,11 @@ module TestaAppiumDriver
|
|
489
465
|
locator
|
490
466
|
end
|
491
467
|
|
492
|
-
|
493
468
|
# @return [TestaAppiumDriver::Locator]
|
494
469
|
def following_siblings
|
495
470
|
raise "Cannot add following_siblings selector to array" unless @single
|
496
471
|
raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "following_siblings") if @strategy != FIND_STRATEGY_XPATH && !@strategy.nil?
|
497
|
-
raise "Cannot add following_siblings selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]")
|
472
|
+
raise "Cannot add following_siblings selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]") && !@from_element.nil?
|
498
473
|
|
499
474
|
locator = self.dup
|
500
475
|
locator.strategy = FIND_STRATEGY_XPATH
|
@@ -510,7 +485,7 @@ module TestaAppiumDriver
|
|
510
485
|
def following_sibling
|
511
486
|
raise "Cannot add following_sibling selector to array" unless @single
|
512
487
|
raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "following_sibling") if @strategy != FIND_STRATEGY_XPATH && !@strategy.nil?
|
513
|
-
raise "Cannot add following_sibling selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]")
|
488
|
+
raise "Cannot add following_sibling selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]") && !@from_element.nil?
|
514
489
|
|
515
490
|
locator = self.dup
|
516
491
|
locator.strategy = FIND_STRATEGY_XPATH
|
@@ -524,7 +499,6 @@ module TestaAppiumDriver
|
|
524
499
|
locator
|
525
500
|
end
|
526
501
|
|
527
|
-
|
528
502
|
private
|
529
503
|
|
530
504
|
def _wait(type, args)
|
@@ -545,10 +519,8 @@ module TestaAppiumDriver
|
|
545
519
|
args.delete(:interval)
|
546
520
|
args.delete(:timeout)
|
547
521
|
|
548
|
-
|
549
|
-
|
550
522
|
start_time = Time.now.to_f
|
551
|
-
if type ==
|
523
|
+
if type == :while
|
552
524
|
while exists? && _attributes_match(args)
|
553
525
|
raise message if start_time + timeout < Time.now.to_f
|
554
526
|
sleep interval
|
@@ -576,7 +548,7 @@ module TestaAppiumDriver
|
|
576
548
|
#noinspection RubyNilAnalysis
|
577
549
|
def perform_driver_method(name, *args)
|
578
550
|
elements = execute
|
579
|
-
if elements.
|
551
|
+
if elements.is_a?(Array)
|
580
552
|
elements.map { |e| e.send(name, *args) }
|
581
553
|
else
|
582
554
|
elements.send(name, *args)
|
@@ -588,7 +560,6 @@ module TestaAppiumDriver
|
|
588
560
|
locator.xpath_selector += hash_to_xpath(@driver.device, selectors, single)
|
589
561
|
end
|
590
562
|
|
591
|
-
|
592
563
|
def handle_image_selector(selectors, params)
|
593
564
|
image_match_threshold = 0.4
|
594
565
|
image_match_threshold = params[:imageMatchThreshold] unless params[:imageMatchThreshold].nil?
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative 'scroll_actions/json_wire_scroll_actions'
|
2
2
|
require_relative 'scroll_actions/w3c_scroll_actions'
|
3
3
|
|
4
|
-
module TestaAppiumDriver
|
4
|
+
module ::TestaAppiumDriver
|
5
5
|
|
6
6
|
# Class for handling scroll actions
|
7
7
|
class ScrollActions
|
@@ -221,9 +221,22 @@ module TestaAppiumDriver
|
|
221
221
|
|
222
222
|
|
223
223
|
def is_end_of_scroll?
|
224
|
-
|
225
|
-
|
226
|
-
|
224
|
+
if @driver.device == :android
|
225
|
+
# $__ctx.puts "end_of_scroll?"
|
226
|
+
# $__ctx.puts "old: #{@previous_elements}"
|
227
|
+
# $__ctx.puts "device: #{@driver.device}"
|
228
|
+
|
229
|
+
old_elements = @previous_elements
|
230
|
+
@previous_elements = @scrollable.first_and_last_leaf
|
231
|
+
# $__ctx.puts "new: #{@previous_elements}"
|
232
|
+
|
233
|
+
old_elements == @previous_elements
|
234
|
+
else
|
235
|
+
# for is, check location of first and last elements
|
236
|
+
old_elements = @previous_elements
|
237
|
+
@previous_elements = @scrollable.first_and_last_child&.map(&:location)
|
238
|
+
old_elements == @previous_elements
|
239
|
+
end
|
227
240
|
end
|
228
241
|
|
229
242
|
def default_deadzone!
|
@@ -10,7 +10,7 @@ require_relative 'common/locator'
|
|
10
10
|
require_relative 'common/scroll_actions'
|
11
11
|
require_relative 'common/selenium_element'
|
12
12
|
|
13
|
-
module TestaAppiumDriver
|
13
|
+
module ::TestaAppiumDriver
|
14
14
|
class Driver
|
15
15
|
include Helpers
|
16
16
|
|
@@ -300,6 +300,13 @@ module TestaAppiumDriver
|
|
300
300
|
[elements[0], elements[-1]]
|
301
301
|
end
|
302
302
|
|
303
|
+
def first_and_last_child(from_element = @driver)
|
304
|
+
elements = from_element.find_elements(xpath: "./*")
|
305
|
+
return nil if elements.count == 0
|
306
|
+
|
307
|
+
[elements[0], elements[-1]]
|
308
|
+
end
|
309
|
+
|
303
310
|
private
|
304
311
|
def extend_for(device, automation_name)
|
305
312
|
case device
|
data/testa_appium_driver.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
|
-
spec.add_runtime_dependency "appium_lib_core", ["
|
33
|
+
spec.add_runtime_dependency "appium_lib_core", ["<= 5.4.0"]
|
34
34
|
spec.add_runtime_dependency "json", ["~> 2.3"]
|
35
35
|
|
36
36
|
spec.add_development_dependency "rubocop", ["= 1.19.0"]
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testa_appium_driver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- karlo.razumovic
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appium_lib_core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "<="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.
|
19
|
+
version: 5.4.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "<="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 5.
|
26
|
+
version: 5.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|