testa_appium_driver 0.1.10 → 0.1.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81983750f782941f5fb92f5261e63e70a7ec3ebfc539d75cdcb0ae89e7466ee1
4
- data.tar.gz: 0ebb35e812a6bbe96b3301e4420fac3ff4cfe0ab4dc6681d4db2b272f7a1fad9
3
+ metadata.gz: 1c55e4e3d29193b3bc89ea292de2c36d093897208050494204da865ea4902d6c
4
+ data.tar.gz: 35014def9a47f5fcfb1242cd1c897a4c13add7f1e9359b66170c2057aa450e3c
5
5
  SHA512:
6
- metadata.gz: 81235f7492aa031cbb25cfda0a74c1e08b14e723b293085e23f145fbf7eff59883fa677720b074306afef4ece650cad6f56e6d5a6f524b5a7eaaa5e160577c47
7
- data.tar.gz: 4ad3449934ca4f3cec3b7b886970eb66fc2dc64207ef4cc14d50d21fb33cc0a232bdbe631922ec34e6a88228ab0735c466d58a6527cd11628f4919dc7199ee15
6
+ metadata.gz: 3562a893791f45303d3cf4cbb3d2b1d1510122ae296e9fb257ce25bd83a9388efacd69ebc9e149219fc5a02fc42f80a9c05f0be72241909b6cd142abfec48e8b
7
+ data.tar.gz: 741a8b9d2b1683484e0100d01c53966d63f9eeacb19ca188589e32b62990ee1cc822d8306e6e23baf34f93ac0a34b929ce5342fdbe1d4a80f3be0e87acf7d28c
@@ -38,7 +38,6 @@ module TestaAppiumDriver
38
38
 
39
39
 
40
40
  def uiautomator_page_or_fling(type, direction)
41
-
42
41
  scrollable_selector = @scrollable.ui_selector(false)
43
42
  orientation = direction == :up || direction == :down ? ".setAsVerticalList()" : ".setAsHorizontalList()"
44
43
  if type == SCROLL_ACTION_TYPE_SCROLL
@@ -70,6 +70,7 @@ module TestaAppiumDriver
70
70
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
71
71
  # @return [TestaAppiumDriver::Locator]
72
72
  def align(with = :top, top: nil, bottom: nil, right: nil, left: nil, scroll_to_find: false)
73
+ deadzone = _process_deadzone(top, bottom, right, left)
73
74
  deadzone = @scrollable_locator.scroll_deadzone if deadzone.nil? && !@scrollable_locator.nil?
74
75
  sa = ScrollActions.new(@scrollable_locator,
75
76
  locator: self,
@@ -139,7 +139,6 @@ module TestaAppiumDriver
139
139
  end
140
140
 
141
141
  def when_exists(timeout = nil, &block)
142
- timeout = @driver.get_timeouts["implicit"] / 1000 if timeout.nil?
143
142
  found = false
144
143
  begin
145
144
  wait_until_exists(timeout)
@@ -161,7 +160,6 @@ module TestaAppiumDriver
161
160
  # @param [Integer] timeout in seconds
162
161
  # @return [TestaAppiumDriver::Locator]
163
162
  def wait_until_exists(timeout = nil)
164
- timeout = @driver.get_timeouts["implicit"] / 1000 if timeout.nil?
165
163
  args = {timeout: timeout}
166
164
  _wait(:until, args)
167
165
  end
@@ -170,7 +168,6 @@ module TestaAppiumDriver
170
168
  # @param [Integer] timeout in seconds
171
169
  # @return [TestaAppiumDriver::Locator]
172
170
  def wait_while_exists(timeout = nil)
173
- timeout = @driver.get_timeouts["implicit"] / 1000 if timeout.nil?
174
171
  args = {timeout: timeout}
175
172
  _wait(:while, args)
176
173
  end
@@ -269,10 +266,8 @@ module TestaAppiumDriver
269
266
  strategy: @strategy,
270
267
  default_strategy: @default_find_strategy,
271
268
  single: @single,
272
- context: @from_element.nil? ? nil : @from_element.to_s,
273
269
  uiautomator: defined?(self.ui_selector) ? ui_selector : nil,
274
270
  xpath: @xpath_selector,
275
- scrollable: @scrollable_locator.nil? ? nil : @scrollable_locator.to_s,
276
271
  scroll_orientation: @scroll_orientation,
277
272
  resolved: strategies_and_selectors,
278
273
  index_for_multiple: @index_for_multiple
@@ -308,19 +303,55 @@ module TestaAppiumDriver
308
303
  end
309
304
 
310
305
 
311
- def tap
312
- click
306
+ def tap(x = nil, y = nil)
307
+ click(x, y)
313
308
  end
314
309
 
315
- def click
316
- if @driver.device == :android
317
- perform_driver_method(:click)
310
+ # if both x or y, or both are not given, will click in the center of the element
311
+ # @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
312
+ # @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
313
+ def click(x = nil, y = nil)
314
+ if !x.nil? && !y.nil?
315
+
316
+ b = self.bounds
317
+ if x.kind_of? Integer
318
+ if x >= 0
319
+ x = b.top_left.x + x
320
+ else
321
+ x = b.bottom_right.x + x
322
+ end
323
+ elsif x.kind_of? Float
324
+ x = b.top_left.x + b.width*x
325
+ else
326
+ raise "x value #{x} not supported"
327
+ end
328
+
329
+ if y.kind_of? Integer
330
+ if y >= 0
331
+ y = b.bottom_right.y + y
332
+ else
333
+ y = b.top_left + y
334
+ end
335
+ elsif y.kind_of? Float
336
+ y = b.bottom_right.y + b.height*y
337
+ end
338
+
339
+ action_builder = @driver.action
340
+ f1 = action_builder.add_pointer_input(:touch, "finger1")
341
+ f1.create_pointer_move(duration: 0, x: x, y: y, origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
342
+ f1.create_pointer_down(:left)
343
+ f1.create_pointer_up(:left)
344
+ @driver.perform_actions [f1]
318
345
  else
319
- # on ios, if element is not visible, first click will scroll to it
320
- # then on second click actually perform the click
321
- visible = visible?
322
- perform_driver_method(:click)
323
- perform_driver_method(:click) unless visible rescue nil
346
+ if @driver.device == :android
347
+ perform_driver_method(:click)
348
+ else
349
+ # on ios, if element is not visible, first click will scroll to it
350
+ # then on second click actually perform the click
351
+ visible = visible?
352
+ perform_driver_method(:click)
353
+ perform_driver_method(:click) unless visible rescue nil
354
+ end
324
355
  end
325
356
  end
326
357
 
@@ -487,7 +518,8 @@ module TestaAppiumDriver
487
518
  message = args[:message] unless args[:message].nil?
488
519
 
489
520
  if args[:timeout].nil?
490
- timeout = @driver.get_timeouts["implicit"] / 1000
521
+ #timeout = @driver.get_timeouts["implicit"] / 1000
522
+ timeout = 10
491
523
  else
492
524
  timeout = args[:timeout]
493
525
  end
@@ -151,7 +151,7 @@ module TestaAppiumDriver
151
151
  @implicit_wait_ms = @implicit_wait_ms/1000 if @implicit_wait_ms > 100000
152
152
  @implicit_wait_uiautomator_ms = @driver.get_settings["waitForSelectorTimeout"]
153
153
  @driver.manage.timeouts.implicit_wait = 0
154
- @driver.update_settings({waitForSelectorTimeout: 0})
154
+ @driver.update_settings({waitForSelectorTimeout: 1})
155
155
  end
156
156
 
157
157
 
@@ -159,7 +159,7 @@ module TestaAppiumDriver
159
159
  def disable_wait_for_idle
160
160
  if @device == :android
161
161
  @wait_for_idle_timeout = @driver.settings.get["waitForIdleTimeout"]
162
- @driver.update_settings({waitForIdleTimeout: 0})
162
+ @driver.update_settings({waitForIdleTimeout: 1})
163
163
  end
164
164
  end
165
165
 
@@ -244,6 +244,36 @@ module TestaAppiumDriver
244
244
  @driver.long_press_keycode(code)
245
245
  end
246
246
 
247
+ def click(x, y)
248
+ ws = driver.window_size
249
+ window_width = ws.width.to_i
250
+ window_height = ws.height.to_i
251
+ if x.kind_of? Integer
252
+ if x < 0
253
+ x = window_width + x
254
+ end
255
+ elsif x.kind_of? Float
256
+ x = window_width*x
257
+ else
258
+ raise "x value #{x} not supported"
259
+ end
260
+
261
+ if y.kind_of? Integer
262
+ if y < 0
263
+ y = window_height + y
264
+ end
265
+ elsif y.kind_of? Float
266
+ y = window_height*y
267
+ end
268
+
269
+
270
+ action_builder = @driver.action
271
+ f1 = action_builder.add_pointer_input(:touch, "finger1")
272
+ f1.create_pointer_move(duration: 0, x: x, y: y, origin: ::Selenium::WebDriver::Interactions::PointerMove::VIEWPORT)
273
+ f1.create_pointer_down(:left)
274
+ f1.create_pointer_up(:left)
275
+ @driver.perform_actions [f1]
276
+ end
247
277
 
248
278
 
249
279
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestaAppiumDriver
4
- VERSION = "0.1.10"
4
+ VERSION = "0.1.11"
5
5
  end
@@ -11,12 +11,12 @@
11
11
  <orderEntry type="sourceFolder" forTests="false" />
12
12
  <orderEntry type="library" scope="PROVIDED" name="appium_lib_core (v4.7.0, ruby-2.6.5-p114) [gem]" level="application" />
13
13
  <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, ruby-2.6.5-p114) [gem]" level="application" />
14
- <orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, ruby-2.6.5-p114) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.24, ruby-2.6.5-p114) [gem]" level="application" />
15
15
  <orderEntry type="library" scope="PROVIDED" name="childprocess (v3.0.0, ruby-2.6.5-p114) [gem]" level="application" />
16
16
  <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.4.4, ruby-2.6.5-p114) [gem]" level="application" />
17
17
  <orderEntry type="library" scope="PROVIDED" name="eventmachine (v1.2.7, ruby-2.6.5-p114) [gem]" level="application" />
18
18
  <orderEntry type="library" scope="PROVIDED" name="faye-websocket (v0.11.1, ruby-2.6.5-p114) [gem]" level="application" />
19
- <orderEntry type="library" scope="PROVIDED" name="json (v2.1.0, ruby-2.6.5-p114) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="json (v2.5.1, ruby-2.6.5-p114) [gem]" level="application" />
20
20
  <orderEntry type="library" scope="PROVIDED" name="parallel (v1.20.1, ruby-2.6.5-p114) [gem]" level="application" />
21
21
  <orderEntry type="library" scope="PROVIDED" name="parser (v3.0.2.0, ruby-2.6.5-p114) [gem]" level="application" />
22
22
  <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, ruby-2.6.5-p114) [gem]" level="application" />
@@ -28,8 +28,8 @@
28
28
  <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.10.1, ruby-2.6.5-p114) [gem]" level="application" />
29
29
  <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.10.2, ruby-2.6.5-p114) [gem]" level="application" />
30
30
  <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.10.2, ruby-2.6.5-p114) [gem]" level="application" />
31
- <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.19.0, ruby-2.6.5-p114) [gem]" level="application" />
32
- <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.10.0, ruby-2.6.5-p114) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.20.0, ruby-2.6.5-p114) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.11.0, ruby-2.6.5-p114) [gem]" level="application" />
33
33
  <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, ruby-2.6.5-p114) [gem]" level="application" />
34
34
  <orderEntry type="library" scope="PROVIDED" name="rubyzip (v2.3.2, ruby-2.6.5-p114) [gem]" level="application" />
35
35
  <orderEntry type="library" scope="PROVIDED" name="selenium-webdriver (v3.142.7, ruby-2.6.5-p114) [gem]" level="application" />
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testa_appium_driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - karlo.razumovic
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-10 00:00:00.000000000 Z
11
+ date: 2022-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appium_lib_core