testa_appium_driver 0.1.18 → 0.1.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +5 -1
  4. data/appium-driver.iml +79 -0
  5. data/testa_appium_driver.gemspec +4 -8
  6. metadata +11 -40
  7. data/.gitattributes +0 -23
  8. data/.gitignore +0 -17
  9. data/.rspec +0 -3
  10. data/.rubocop.yml +0 -5
  11. data/bin/console +0 -17
  12. data/bin/setup +0 -8
  13. data/lib/testa_appium_driver/android/class_selectors.rb +0 -438
  14. data/lib/testa_appium_driver/android/driver.rb +0 -71
  15. data/lib/testa_appium_driver/android/locator/attributes.rb +0 -118
  16. data/lib/testa_appium_driver/android/locator.rb +0 -142
  17. data/lib/testa_appium_driver/android/scroll_actions/uiautomator_scroll_actions.rb +0 -62
  18. data/lib/testa_appium_driver/android/selenium_element.rb +0 -12
  19. data/lib/testa_appium_driver/common/bounds.rb +0 -150
  20. data/lib/testa_appium_driver/common/constants.rb +0 -38
  21. data/lib/testa_appium_driver/common/exceptions/strategy_mix_exception.rb +0 -12
  22. data/lib/testa_appium_driver/common/helpers.rb +0 -271
  23. data/lib/testa_appium_driver/common/locator/scroll_actions.rb +0 -398
  24. data/lib/testa_appium_driver/common/locator.rb +0 -599
  25. data/lib/testa_appium_driver/common/scroll_actions/json_wire_scroll_actions.rb +0 -4
  26. data/lib/testa_appium_driver/common/scroll_actions/w3c_scroll_actions.rb +0 -305
  27. data/lib/testa_appium_driver/common/scroll_actions.rb +0 -267
  28. data/lib/testa_appium_driver/common/selenium_element.rb +0 -19
  29. data/lib/testa_appium_driver/driver.rb +0 -335
  30. data/lib/testa_appium_driver/ios/driver.rb +0 -49
  31. data/lib/testa_appium_driver/ios/locator/attributes.rb +0 -85
  32. data/lib/testa_appium_driver/ios/locator.rb +0 -72
  33. data/lib/testa_appium_driver/ios/selenium_element.rb +0 -8
  34. data/lib/testa_appium_driver/ios/type_selectors.rb +0 -188
  35. data/lib/testa_appium_driver/version.rb +0 -5
  36. data/lib/testa_appium_driver.rb +0 -6
@@ -1,599 +0,0 @@
1
- require_relative 'locator/scroll_actions'
2
-
3
- module ::TestaAppiumDriver
4
- #noinspection RubyTooManyInstanceVariablesInspection,RubyTooManyMethodsInspection
5
- class Locator
6
- include Helpers
7
-
8
- attr_accessor :xpath_selector
9
- attr_accessor :single
10
-
11
- attr_accessor :driver
12
- attr_accessor :strategy
13
- attr_accessor :strategy_reason
14
-
15
- # @type [Boolean] used to determine if last selector was one of siblings or children. Only in those selectors we can reliably use xpath array [instance] selector
16
- attr_accessor :last_selector_adjacent
17
- attr_accessor :can_use_id_strategy
18
-
19
- attr_accessor :image_selector
20
-
21
- attr_accessor :from_element
22
- attr_accessor :scroll_orientation
23
- attr_accessor :scroll_deadzone
24
- attr_accessor :scrollable_locator
25
-
26
- attr_accessor :default_find_strategy
27
- attr_accessor :default_scroll_strategy
28
-
29
- attr_accessor :index_for_multiple
30
-
31
- # locator parameters are:
32
- # single: true or false
33
- # scrollable_locator: [TestaAppiumDriver::Locator, nil] for scrolling if needed later
34
- # default_find_strategy: default strategy if find element strategy is not enforced
35
- # default_scroll_strategy: default strategy for scrolling if not enforced
36
- #
37
- # @param [TestaAppiumDriver::Driver] driver
38
- # @param [TestaAppiumDriver::Driver, TestaAppiumDriver::Locator, Selenium::WebDriver::Element] from_element from which element to execute the find_element
39
- # @param [Hash] params selectors and params for locator
40
- def initialize(driver, from_element, params = {})
41
- # @type [TestaAppiumDriver::Driver]
42
- @driver = driver
43
- @index_for_multiple = nil
44
- @image_selector = nil
45
-
46
- params, selectors = extract_selectors_from_params(params)
47
- single = params[:single]
48
-
49
- @single = single
50
-
51
- if selectors[:image].nil?
52
- if from_element.instance_of?(TestaAppiumDriver::Locator) && !from_element.image_selector.nil?
53
- raise "Cannot chain non-image selectors to image selectors"
54
- end
55
- else
56
- handle_image_selector(selectors, params)
57
- end
58
-
59
- selectors[:id] = selectors[:name] unless selectors[:name].nil?
60
- if from_element.instance_of?(::Selenium::WebDriver::Element) || from_element.instance_of?(::Appium::Core::Element) || from_element.instance_of?(::TestaAppiumDriver::Locator)
61
- @xpath_selector = "."
62
- @xpath_selector += hash_to_xpath(@driver.device, selectors, single)
63
- else
64
- @xpath_selector = hash_to_xpath(@driver.device, selectors, single)
65
- end
66
-
67
- @from_element = from_element
68
- @default_find_strategy = params[:default_find_strategy]
69
- @default_scroll_strategy = params[:default_scroll_strategy]
70
-
71
- @can_use_id_strategy = is_only_id_selector?(selectors)
72
- if @can_use_id_strategy
73
- if @driver.device == :android
74
- @can_use_id_strategy = resolve_id(selectors[:id])
75
- else
76
- @can_use_id_strategy = selectors[:id]
77
- end
78
- end
79
-
80
- @strategy = params[:strategy]
81
- @strategy_reason = params[:strategy_reason]
82
-
83
- @last_selector_adjacent = false
84
-
85
- init(params, selectors, single)
86
- end
87
-
88
- def is_only_id_selector?(selectors)
89
- # since, name and id is the same thing for iOS,
90
- if @driver.device == :android
91
- selectors.keys.count == 1 && !selectors[:id].nil?
92
- else
93
- # if it iOS we assign the name to id
94
- selectors.keys.count == 2 && !selectors[:id].nil? && selectors[:id] == selectors[:name]
95
- end
96
- end
97
-
98
- # method missing is used to fetch the element before executing additional commands like click, send_key, count
99
- def method_missing(method, *args, &block)
100
- r = execute.send(method, *args, &block)
101
- @driver.invalidate_cache
102
- r
103
- end
104
-
105
- # @param [Boolean] skip_cache if true it will skip cache check and store
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
107
- # @return [Selenium::WebDriver::Element, Array]
108
- def execute(skip_cache: false, force_cache_element: nil, ignore_implicit_wait: false)
109
- return force_cache_element unless force_cache_element.nil?
110
- # if we are looking for current element, then return from_element
111
- # for example when we have driver.element.elements[1].click
112
- # elements[2] will be resolved with xpath because we are looking for multiple elements from element
113
- # and since we are looking for instance 2, [](instance) method will return new "empty locator"
114
- # we are executing click on that "empty locator" so we have to return the instance 2 of elements for the click
115
- if @xpath_selector == ".//*[1]" && !@from_element.nil? && @image_selector.nil?
116
- return @from_element if @from_element.instance_of?(::Selenium::WebDriver::Element) || @from_element.instance_of?(::Appium::Core::Element)
117
- return @from_element.execute(skip_cache: skip_cache, force_cache_element: force_cache_element, ignore_implicit_wait: ignore_implicit_wait) if @from_element.instance_of?(TestaAppiumDriver::Locator)
118
- return @from_element
119
- end
120
-
121
- r = @driver.execute(@from_element, @single, strategies_and_selectors, skip_cache: skip_cache, ignore_implicit_wait: ignore_implicit_wait)
122
- r = r[@index_for_multiple] if !@index_for_multiple.nil? && !@single
123
- r
124
- end
125
-
126
- def when_exists(timeout = nil, &block)
127
- found = false
128
- begin
129
- wait_until_exists(timeout)
130
- found = true
131
- rescue
132
- #ignored
133
- end
134
- if found
135
- if block_given? # block is given
136
- block.call(self) # use call to execute the block
137
- else
138
- # the value of block_argument becomes nil if you didn't give a block
139
- # block was not given
140
- end
141
- end
142
- self
143
- end
144
-
145
- # @param [Integer] timeout in seconds
146
- # @return [TestaAppiumDriver::Locator]
147
- def wait_until_exists(timeout = nil)
148
- args = { timeout: timeout }
149
- _wait(:until, args)
150
- end
151
-
152
- # @param [Integer] timeout in seconds
153
- # @return [TestaAppiumDriver::Locator]
154
- def wait_while_exists(timeout = nil)
155
- args = { timeout: timeout }
156
- _wait(:while, args)
157
- end
158
-
159
- def wait_while(timeout = nil, args = {})
160
- args[:timeout] = timeout
161
- _wait(:while, args)
162
- end
163
-
164
- def wait_until(timeout = nil, args = {})
165
- args[:timeout] = timeout
166
- _wait(:until, args)
167
- end
168
-
169
- # all timeouts are disabled before check, and enabled after check
170
- # @return [boolean] true if it exists in the page regardless if visible or not
171
- def exists?
172
- found = true
173
- begin
174
- r = execute(skip_cache: true, ignore_implicit_wait: true)
175
- return r.count.positive? if r.is_a?(Array)
176
- rescue StandardError
177
- found = false
178
- end
179
- found
180
- end
181
-
182
- # @return [TestaAppiumDriver::Locator]
183
- def first
184
- self[0]
185
- end
186
-
187
- # @return [TestaAppiumDriver::Locator]
188
- def second
189
- self[1]
190
- end
191
-
192
- # @return [TestaAppiumDriver::Locator]
193
- def third
194
- self[2]
195
- end
196
-
197
- # @return [TestaAppiumDriver::Locator]
198
- def last
199
- self[-1]
200
- end
201
-
202
- def [](instance)
203
- raise "Cannot add index selector to non-Array" if @single
204
- if ((@strategy.nil? && !@last_selector_adjacent && @driver.device == :android) || @strategy == FIND_STRATEGY_UIAUTOMATOR) && instance >= 0
205
- locator = self.dup
206
- locator.strategy = FIND_STRATEGY_UIAUTOMATOR
207
- locator.ui_selector = "#{@ui_selector}.instance(#{instance})"
208
- locator.single = true
209
- locator.can_use_id_strategy = false
210
- locator
211
- elsif (@driver.device == :ios && !@last_selector_adjacent && @strategy.nil?) || @strategy == FIND_STRATEGY_CLASS_CHAIN
212
- locator = self.dup
213
- locator.strategy = FIND_STRATEGY_CLASS_CHAIN
214
- locator.class_chain_selector += "[#{instance + 1}]"
215
- locator.single = true
216
- locator.can_use_id_strategy = false
217
- locator
218
- else
219
- from_element = self.dup
220
- from_element.index_for_multiple = instance
221
- params = {}.merge({ single: true, scrollable_locator: @scrollable_locator })
222
- #params[:strategy] = FIND_STRATEGY_XPATH
223
- #params[:strategy_reason] = "retrieved instance of a array"
224
- params[:default_find_strategy] = @default_find_strategy
225
- params[:default_scroll_strategy] = @default_scroll_strategy
226
- Locator.new(@driver, from_element, params)
227
- end
228
- end
229
-
230
- # @param [TestaAppiumDriver::Locator, Selenium::WebDriver::Element, Array] other
231
- #noinspection RubyNilAnalysis,RubyUnnecessaryReturnStatement
232
- def ==(other)
233
- elements = execute
234
- other = other.execute if other.is_a?(TestaAppiumDriver::Locator)
235
-
236
- if elements.is_a?(Array)
237
- return false unless other.is_a?(Array)
238
- return false if other.count != elements.count
239
- return (elements - other).empty?
240
- else
241
- return false if other.is_a?(Array)
242
- return elements == other
243
- end
244
- end
245
-
246
- def as_json
247
- {
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
256
- }
257
- end
258
-
259
- def to_s
260
- JSON.dump(as_json)
261
- end
262
-
263
- def to_ary
264
- [self.to_s]
265
- end
266
-
267
- # @return [TestaAppiumDriver::Locator]
268
- def as_scrollable(orientation: :vertical, top: nil, bottom: nil, right: nil, left: nil)
269
- @scroll_orientation = orientation
270
- if !top.nil? || !bottom.nil? || !right.nil? || !left.nil?
271
- @scroll_deadzone = {}
272
- @scroll_deadzone[:top] = top.to_f unless top.nil?
273
- @scroll_deadzone[:bottom] = bottom.to_f unless bottom.nil?
274
- @scroll_deadzone[:right] = right.to_f unless right.nil?
275
- @scroll_deadzone[:left] = left.to_f unless left.nil?
276
- end
277
- @scrollable_locator = self.dup
278
- self
279
- end
280
-
281
- def first_and_last_leaf
282
- @driver.first_and_last_leaf(execute)
283
- end
284
-
285
- def first_and_last_child
286
- @driver.first_and_last_child(execute)
287
- end
288
-
289
- def double_click(x = nil, y = nil)
290
- click(x, y, double: true)
291
- end
292
-
293
- # if both x or y, or both are not given, will click in the center of the element
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
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
296
- def click(x = nil, y = nil, double: false, by_coords: false)
297
- if !x.nil? && !y.nil? || double || by_coords
298
-
299
- x = 0.5 if x.nil?
300
- y = 0.5 if y.nil?
301
-
302
- b = self.bounds
303
- if x.is_a?(Integer)
304
- if x >= 0
305
- x = b.top_left.x + x
306
- else
307
- x = b.bottom_right.x + x
308
- end
309
- elsif x.is_a?(Float) && x <= 1.0 && x >= 0
310
- x = b.top_left.x + b.width * x
311
- else
312
- raise "x value #{x} not supported. Use integer as pixel or float (0..1) as percentage of element width"
313
- end
314
-
315
- if y.is_a?(Integer)
316
- if y >= 0
317
- y = b.top_left.y + y
318
- else
319
- y = b.bottom_right + y
320
- end
321
- elsif y.is_a?(Float) && y <= 1.0 && y >= 0
322
- y = b.top_left.y + b.height * y
323
- else
324
- raise "y value #{x} not supported. Use integer as pixel or float (0..1) as percentage of element height"
325
- end
326
-
327
- action_builder = @driver.action
328
- f1 = action_builder.add_pointer_input(:touch, "finger1")
329
- f1.create_pointer_move(duration: 0, x: x, y: y, origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
330
- f1.create_pointer_down(:left)
331
- f1.create_pointer_up(:left)
332
- if double
333
- f1.create_pause(0.1)
334
- f1.create_pointer_down(:left)
335
- f1.create_pointer_up(:left)
336
- end
337
- @driver.perform_actions [f1]
338
- else
339
- if @driver.device == :android
340
- perform_driver_method(:click)
341
- else
342
- # on ios, if element is not visible, first click will scroll to it
343
- # then on second click actually perform the click
344
- #visible = visible?
345
- perform_driver_method(:click)
346
- #perform_driver_method(:click) unless visible rescue nil
347
- end
348
- end
349
- end
350
-
351
- alias_method :tap, :click
352
- alias_method :double_tap, :double_click
353
-
354
- def send_key(*args)
355
- perform_driver_method(:send_keys, *args)
356
- end
357
-
358
- def clear
359
- perform_driver_method(:clear)
360
- end
361
-
362
- # Return parent element
363
- # @return [TestaAppiumDriver::Locator]
364
- def parent
365
- raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "parent") if @strategy != FIND_STRATEGY_XPATH && !@strategy.nil?
366
- raise "Cannot add parent selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]") && !@from_element.nil?
367
-
368
- locator = self.dup
369
- locator.strategy = FIND_STRATEGY_XPATH
370
- locator.strategy_reason = "parent"
371
- locator.xpath_selector += "/.."
372
- locator.can_use_id_strategy = false
373
- locator
374
- end
375
-
376
- # Return all children elements
377
- # @return [TestaAppiumDriver::Locator]
378
- def children
379
- raise "Cannot add children selector to array" unless @single
380
- raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "children") if @strategy != FIND_STRATEGY_XPATH && @strategy != FIND_STRATEGY_CLASS_CHAIN && !@strategy.nil?
381
-
382
- locator = self.dup
383
- locator.strategy_reason = "children"
384
- locator.xpath_selector += "/*"
385
- locator.single = false
386
- locator.last_selector_adjacent = true
387
- locator.can_use_id_strategy = false
388
-
389
- if @driver.device == :android
390
- locator.strategy = FIND_STRATEGY_XPATH
391
- else
392
- locator.class_chain_selector += "/*"
393
- end
394
- locator
395
- end
396
-
397
- # Return first child element
398
- # @return [TestaAppiumDriver::Locator]
399
- def child
400
- raise "Cannot add children selector to array" unless @single
401
- raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "child") if @strategy != FIND_STRATEGY_XPATH && @strategy != FIND_STRATEGY_CLASS_CHAIN && !@strategy.nil?
402
-
403
- locator = self.dup
404
-
405
- locator.strategy_reason = "child"
406
- locator.xpath_selector += "/*[1]"
407
- locator.single = true
408
- locator.can_use_id_strategy = false
409
-
410
- if @driver.device == :android
411
- locator.strategy = FIND_STRATEGY_XPATH
412
- else
413
- locator.class_chain_selector += "/*[1]"
414
- end
415
- locator
416
- end
417
-
418
- # @return [TestaAppiumDriver::Locator]
419
- def siblings
420
- raise "Cannot add siblings selector to array" unless @single
421
- raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "siblings") if @strategy != FIND_STRATEGY_XPATH && !@strategy.nil?
422
- raise "Cannot add siblings selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]") && !@from_element.nil?
423
-
424
- locator = self.dup
425
- locator.strategy = FIND_STRATEGY_XPATH
426
- locator.strategy_reason = "siblings"
427
- locator.xpath_selector += "/../*[not(@index=\"#{index}\")]"
428
- locator.single = false
429
- locator.last_selector_adjacent = true
430
- locator.can_use_id_strategy = false
431
- locator
432
- end
433
-
434
- # @return [TestaAppiumDriver::Locator]
435
- def preceding_siblings
436
- raise "Cannot add preceding_siblings selector to array" unless @single
437
- raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "preceding_siblings") if @strategy != FIND_STRATEGY_XPATH && !@strategy.nil?
438
- raise "Cannot add preceding_siblings selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]") && !@from_element.nil?
439
-
440
- locator = self.dup
441
- locator.strategy = FIND_STRATEGY_XPATH
442
- locator.strategy_reason = "preceding_siblings"
443
- locator.xpath_selector += "/../*[position() < #{index + 1}]" # position() starts from 1
444
- locator.single = false
445
- locator.last_selector_adjacent = true
446
- locator.can_use_id_strategy = false
447
- locator
448
- end
449
-
450
- # @return [TestaAppiumDriver::Locator]
451
- def preceding_sibling
452
- raise "Cannot add preceding_sibling selector to array" unless @single
453
- raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "preceding_sibling") if @strategy != FIND_STRATEGY_XPATH && !@strategy.nil?
454
- raise "Cannot add preceding siblings selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]") && !@from_element.nil?
455
-
456
- locator = self.dup
457
- locator.strategy = FIND_STRATEGY_XPATH
458
- locator.strategy_reason = "preceding_sibling"
459
- i = index
460
- locator.single = true
461
- return nil if i == 0
462
- locator.xpath_selector += "/../*[@index=\"#{i - 1}\"]"
463
- locator.last_selector_adjacent = true
464
- locator.can_use_id_strategy = false
465
- locator
466
- end
467
-
468
- # @return [TestaAppiumDriver::Locator]
469
- def following_siblings
470
- raise "Cannot add following_siblings selector to array" unless @single
471
- raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "following_siblings") if @strategy != FIND_STRATEGY_XPATH && !@strategy.nil?
472
- raise "Cannot add following_siblings selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]") && !@from_element.nil?
473
-
474
- locator = self.dup
475
- locator.strategy = FIND_STRATEGY_XPATH
476
- locator.strategy_reason = "following_siblings"
477
- locator.xpath_selector += "/../*[position() > #{index + 1}]" # position() starts from 1
478
- locator.single = false
479
- locator.last_selector_adjacent = true
480
- locator.can_use_id_strategy = false
481
- locator
482
- end
483
-
484
- # @return [TestaAppiumDriver::Locator]
485
- def following_sibling
486
- raise "Cannot add following_sibling selector to array" unless @single
487
- raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "following_sibling") if @strategy != FIND_STRATEGY_XPATH && !@strategy.nil?
488
- raise "Cannot add following_sibling selector to a retrieved instance of a class array" if (@xpath_selector == ".//*" || @xpath_selector == ".//*[1]") && !@from_element.nil?
489
-
490
- locator = self.dup
491
- locator.strategy = FIND_STRATEGY_XPATH
492
- locator.strategy_reason = "following_sibling"
493
- i = index
494
- locator.single = true
495
- return nil if i == 0
496
- locator.xpath_selector += "/../*[@index=\"#{i + 1}\"]"
497
- locator.last_selector_adjacent = true
498
- locator.can_use_id_strategy = false
499
- locator
500
- end
501
-
502
- private
503
-
504
- def _wait(type, args)
505
- interval = EXISTS_WAIT
506
- interval = args[:interval] unless args[:interval].nil?
507
-
508
- message = "wait #{type} exists timeout exceeded"
509
- message = args[:message] unless args[:message].nil?
510
-
511
- if args[:timeout].nil?
512
- #timeout = @driver.get_timeouts["implicit"] / 1000
513
- timeout = 10
514
- else
515
- timeout = args[:timeout]
516
- end
517
-
518
- args.delete(:message)
519
- args.delete(:interval)
520
- args.delete(:timeout)
521
-
522
- start_time = Time.now.to_f
523
- if type == :while
524
- while exists? && _attributes_match(args)
525
- raise message if start_time + timeout < Time.now.to_f
526
- sleep interval
527
- end
528
- else
529
- until exists? && _attributes_match(args)
530
- raise message if start_time + timeout < Time.now.to_f
531
- sleep interval
532
- end
533
- end
534
- self
535
- end
536
-
537
- def _attributes_match(attributes)
538
- all_match = true
539
- attributes.each do |key, value|
540
- unless testa_attribute(key) == value
541
- all_match = false
542
- break
543
- end
544
- end
545
- all_match
546
- end
547
-
548
- #noinspection RubyNilAnalysis
549
- def perform_driver_method(name, *args)
550
- elements = execute
551
- if elements.is_a?(Array)
552
- elements.map { |e| e.send(name, *args) }
553
- else
554
- elements.send(name, *args)
555
- end
556
- end
557
-
558
- def add_xpath_child_selectors(locator, selectors, single)
559
- locator.single = false unless single # switching from single result to multiple
560
- locator.xpath_selector += hash_to_xpath(@driver.device, selectors, single)
561
- end
562
-
563
- def handle_image_selector(selectors, params)
564
- image_match_threshold = 0.4
565
- image_match_threshold = params[:imageMatchThreshold] unless params[:imageMatchThreshold].nil?
566
- image_match_threshold = params[:threshold] unless params[:threshold].nil?
567
- fix_image_find_screenshot_dims = true
568
- fix_image_find_screenshot_dims = params[:fixImageFindScreenshotDims] unless params[:fixImageFindScreenshotDims].nil?
569
- fix_image_template_size = false
570
- fix_image_template_size = params[:fixImageTemplateSize] unless params[:fixImageTemplateSize].nil?
571
- fix_image_template_scale = false
572
- fix_image_template_scale = params[:fixImageTemplateScale] unless params[:fixImageTemplateScale].nil?
573
- default_image_template_scale = 1.0
574
- default_image_template_scale = params[:defaultImageTemplateScale] unless params[:defaultImageTemplateScale].nil?
575
- check_for_image_element_staleness = true
576
- check_for_image_element_staleness = params[:checkForImageElementStaleness] unless params[:checkForImageElementStaleness].nil?
577
- auto_update_image_element_position = false
578
- auto_update_image_element_position = params[:autoUpdateImageElementPosition] unless params[:autoUpdateImageElementPosition].nil?
579
- image_element_tap_strategy = "w3cActions"
580
- image_element_tap_strategy = params[:imageElementTapStrategy] unless params[:imageElementTapStrategy].nil?
581
- get_matched_image_result = false
582
- get_matched_image_result = params[:getMatchedImageResult] unless params[:getMatchedImageResult].nil?
583
-
584
- @image_selector = {
585
- image: selectors[:image],
586
- imageMatchThreshold: image_match_threshold,
587
- fixImageFindScreenshotDims: fix_image_find_screenshot_dims,
588
- fixImageTemplateSize: fix_image_template_size,
589
- fixImageTemplateScale: fix_image_template_scale,
590
- defaultImageTemplateScale: default_image_template_scale,
591
- checkForImageElementStaleness: check_for_image_element_staleness,
592
- autoUpdateImageElementPosition: auto_update_image_element_position,
593
- imageElementTapStrategy: image_element_tap_strategy,
594
- getMatchedImageResult: get_matched_image_result,
595
- }
596
- end
597
- end
598
-
599
- end
@@ -1,4 +0,0 @@
1
- module TestaAppiumDriver
2
- module JsonWireScrollActions
3
- end
4
- end