testa_appium_driver 0.1.32 → 0.1.33

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: add83f6c9df4e695d9c8869c37d15611e0b87a065c6f844828264784e6d333a5
4
- data.tar.gz: fa96bc1504a4863534aa9557041ce611594e6267c75f8b6a2d300a42605652d3
3
+ metadata.gz: 593c2444720244c32d1a237a40ed80b3f864595bd5f1f5a197fbf87790b0b8af
4
+ data.tar.gz: 5da6b35f561eb2deae604705957ce8a220f4d5dd940728188d67096c9c6c3a7b
5
5
  SHA512:
6
- metadata.gz: b2fac94a46daef9a2782cc854f959434cc811ea3d853021c626c2b3eb12f9b80b8ce98e666472e916f0f2968524828c6635b9f52f5b0473a9a2f5ab92b230aef
7
- data.tar.gz: 23f90e32e4c4bb11893a5140202b11a6c7d81681833cd3525539ae470144bce5f92611e57b6c0ac75c90cf6f357183e7c38791d123991d21728d2bdc86a0b4b3
6
+ metadata.gz: 142dbf94253246348e3802542de308034ba5286286824411d5ae5b711147e5201817bac6951c77286c7a52dd6f4c36d408aa474db860189484535b195846ea89
7
+ data.tar.gz: 1918230241d2f531bffb5205125dff3cafff25b3d997b219807a1e860ccb34d0ee41082ef4a954c5481101a77885e691364d295d2dee9e580ab730a00ac676a1
@@ -1,7 +1,7 @@
1
1
  module TestaAppiumDriver
2
2
  module Attributes
3
3
 
4
- #noinspection RubyNilAnalysis
4
+ # noinspection RubyNilAnalysis
5
5
  def testa_attribute(name, *args)
6
6
  if self.instance_of?(::Selenium::WebDriver::Element) || self.instance_of?(::Appium::Core::Element)
7
7
  @driver = get_driver # does not get correct driver
@@ -10,13 +10,19 @@ module TestaAppiumDriver
10
10
  elements = execute(*args)
11
11
  raise "Element not found" if elements.nil?
12
12
  end
13
-
13
+
14
14
  if elements.kind_of?(::Selenium::WebDriver::Element) || elements.kind_of?(::Appium::Core::Element)
15
- r = elements.send(:attribute, name.to_s)
16
- r = TestaAppiumDriver::Bounds.from_android(r, @driver) if name.to_s == "bounds"
15
+ if name.to_sym == :bounds
16
+ refresh_element = elements.find_element(xpath: ".")
17
+ r = TestaAppiumDriver::Bounds.from_android(refresh_element.send(:attribute, name), @driver)
18
+ else
19
+ r = elements.send(:attribute, name.to_s)
20
+ end
17
21
  else
22
+ # refreshing each element in collection would be too slow
23
+ # ignore the possibility that the bounds could be stale
18
24
  r = elements.map { |e| e.send(:attribute, name.to_s) }
19
- r.map! { |b| TestaAppiumDriver::Bounds.from_android(b, @driver) } if name.to_s == "bounds"
25
+ r.map! { |b| TestaAppiumDriver::Bounds.from_android(b, @driver) } if name.to_sym == :bounds
20
26
  end
21
27
  r
22
28
  end
@@ -101,7 +107,7 @@ module TestaAppiumDriver
101
107
  class Locator
102
108
 
103
109
  # element index in parent element, starts from 0
104
- #noinspection RubyNilAnalysis,RubyYardReturnMatch
110
+ # noinspection RubyNilAnalysis,RubyYardReturnMatch
105
111
  # @return [Integer, nil] index of element
106
112
  def index(*args)
107
113
  raise "Index not supported for uiautomator strategy" if @strategy == FIND_STRATEGY_UIAUTOMATOR
@@ -9,4 +9,4 @@ module ::Appium
9
9
  end
10
10
  end
11
11
  end
12
- end
12
+ end
@@ -8,7 +8,6 @@ module TestaAppiumDriver
8
8
  attr_reader :height
9
9
  attr_reader :offset
10
10
 
11
-
12
11
  # @param top_left [Coordinates]
13
12
  # @param bottom_right [Coordinates]
14
13
  # @param window_width [Integer]
@@ -19,7 +18,7 @@ module TestaAppiumDriver
19
18
  @width = bottom_right.x - top_left.x
20
19
  @height = bottom_right.y - top_left.y
21
20
  @offset = Offset.new(self, window_width, window_height)
22
- @center = TestaAppiumDriver::Coordinates.new(@top_left.x + @width/2, @top_left.y + @height / 2)
21
+ @center = TestaAppiumDriver::Coordinates.new(@top_left.x + @width / 2, @top_left.y + @height / 2)
23
22
  end
24
23
 
25
24
  def as_json
@@ -28,7 +27,7 @@ module TestaAppiumDriver
28
27
  height: @height,
29
28
  top_left: @top_left.as_json,
30
29
  bottom_right: @bottom_right.as_json,
31
- offset: @offset.as_json
30
+ offset: @offset.as_json,
32
31
  }
33
32
  end
34
33
 
@@ -41,6 +40,7 @@ module TestaAppiumDriver
41
40
  def top_left
42
41
  @top_left
43
42
  end
43
+
44
44
  # @return [TestaAppiumDriver::Coordinates]
45
45
  def bottom_right
46
46
  @bottom_right
@@ -51,8 +51,12 @@ module TestaAppiumDriver
51
51
  @center
52
52
  end
53
53
 
54
+ def ai
55
+ as_json.ai
56
+ end
57
+
54
58
  def to_s
55
- JSON.dump(as_json)
59
+ "[#{@top_left.x}, #{@top_left.y}][#{@bottom_right.x}, #{@bottom_right.y}]"
56
60
  end
57
61
 
58
62
  # @param bounds [String] bounds that driver.attribute("bounds") return
@@ -81,7 +85,7 @@ module TestaAppiumDriver
81
85
  end
82
86
  end
83
87
 
84
- #noinspection ALL
88
+ # noinspection ALL
85
89
  class Coordinates
86
90
  def initialize(x, y)
87
91
  @x = x.to_i
@@ -95,7 +99,6 @@ module TestaAppiumDriver
95
99
  }
96
100
  end
97
101
 
98
-
99
102
  # @return [Integer]
100
103
  def x
101
104
  @x
@@ -107,7 +110,6 @@ module TestaAppiumDriver
107
110
  end
108
111
  end
109
112
 
110
-
111
113
  class Offset
112
114
  def initialize(bounds, window_width, window_height)
113
115
  @top = bounds.top_left.y
@@ -125,7 +127,6 @@ module TestaAppiumDriver
125
127
  }
126
128
  end
127
129
 
128
-
129
130
  # @return [Integer]
130
131
  def top
131
132
  @top
@@ -147,4 +148,4 @@ module TestaAppiumDriver
147
148
  end
148
149
 
149
150
  end
150
- end
151
+ end
@@ -110,7 +110,7 @@ module TestaAppiumDriver
110
110
  # If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
111
111
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
112
112
  # @return [TestaAppiumDriver::Locator]
113
- def align_right(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
113
+ def align_right(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
114
114
  align(:right, top: top, bottom: bottom, right: right, left: left, max_attempts: max_attempts)
115
115
  end
116
116
 
@@ -119,7 +119,7 @@ module TestaAppiumDriver
119
119
  # If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
120
120
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
121
121
  # @return [TestaAppiumDriver::Locator]
122
- def align!(with = :top, top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
122
+ def align!(with = :top, top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
123
123
  align(with, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true, max_attempts: max_attempts)
124
124
  end
125
125
 
@@ -137,7 +137,7 @@ module TestaAppiumDriver
137
137
  # If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
138
138
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
139
139
  # @return [TestaAppiumDriver::Locator]
140
- def align_bottom!(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
140
+ def align_bottom!(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
141
141
  align(:bottom, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true, max_attempts: max_attempts)
142
142
  end
143
143
 
@@ -146,7 +146,7 @@ module TestaAppiumDriver
146
146
  # If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
147
147
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
148
148
  # @return [TestaAppiumDriver::Locator]
149
- def align_left!(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
149
+ def align_left!(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
150
150
  align(:left, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true, max_attempts: max_attempts)
151
151
  end
152
152
 
@@ -155,7 +155,7 @@ module TestaAppiumDriver
155
155
  # If the distance is greater than the threshold, it will attempt to realign it up to 2 more times.
156
156
  # The retry mechanism allows alignment even for dynamic layouts when elements are hidden/show when scrolling to certain direction
157
157
  # @return [TestaAppiumDriver::Locator]
158
- def align_right!(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
158
+ def align_right!(top: nil, bottom: nil, right: nil, left: nil, max_attempts: 3)
159
159
  align(:right, top: top, bottom: bottom, right: right, left: left, scroll_to_find: true, max_attempts: max_attempts)
160
160
  end
161
161
 
@@ -269,7 +269,12 @@ module TestaAppiumDriver
269
269
  end
270
270
 
271
271
  if to.kind_of?(::Selenium::WebDriver::Element) || to.kind_of?(::Appium::Core::Element)
272
- bounds = TestaAppiumDriver::Bounds.from_android(to.bounds, @driver)
272
+ if @driver.device == :android
273
+ bounds = TestaAppiumDriver::Bounds.from_android(to.bounds, @driver)
274
+ else
275
+ bounds = TestaAppiumDriver::Bounds.from_ios(to.bounds, @driver)
276
+ end
277
+
273
278
  x = bounds.center.x
274
279
  y = bounds.center.y
275
280
  end
@@ -308,6 +313,7 @@ module TestaAppiumDriver
308
313
  end
309
314
 
310
315
  private
316
+
311
317
  def _process_deadzone(top, bottom, right, left)
312
318
  deadzone = nil
313
319
  if !top.nil? || !bottom.nil? || !right.nil? || !left.nil?
@@ -207,25 +207,25 @@ module ::TestaAppiumDriver
207
207
  when :top
208
208
  y0 = @bounds.bottom_right.y - @deadzone[:bottom]
209
209
  y1 = y0 - @align_offset
210
- x0 = @bounds.width / 2
210
+ x0 = @bounds.center.x
211
211
  x1 = x0
212
212
  scroll_direction = :down
213
213
  when :bottom
214
214
  y0 = @bounds.top_left.y + @deadzone[:top]
215
215
  y1 = y0 + @align_offset
216
- x0 = @bounds.width / 2
216
+ x0 = @bounds.center.x
217
217
  x1 = x0
218
218
  scroll_direction = :up
219
219
  when :left
220
220
  x0 = @bounds.bottom_right.x - @deadzone[:right]
221
221
  x1 = x0 - @align_offset
222
- y0 = @bounds.height / 2
222
+ y0 = @bounds.center.y
223
223
  y1 = y0
224
224
  scroll_direction = :right
225
225
  when :right
226
226
  x0 = @bounds.top_left.x + @deadzone[:top]
227
227
  x1 = x0 + @align_offset
228
- y0 = @bounds.height / 2
228
+ y0 = @bounds.center.y
229
229
  y1 = y0
230
230
  scroll_direction = :left
231
231
  else
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.32
4
+ version: 0.1.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - karlo.razumovic
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-16 00:00:00.000000000 Z
11
+ date: 2024-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appium_lib_core
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: awesome_print
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: json
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -90,7 +104,7 @@ metadata:
90
104
  homepage_uri: https://github.com/Karazum/testa_appium_driver
91
105
  source_code_uri: https://github.com/Karazum/testa_appium_driver
92
106
  changelog_uri: https://github.com/Karazum/testa_appium_driver
93
- post_install_message:
107
+ post_install_message:
94
108
  rdoc_options: []
95
109
  require_paths:
96
110
  - lib
@@ -106,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
120
  version: '0'
107
121
  requirements: []
108
122
  rubygems_version: 3.1.6
109
- signing_key:
123
+ signing_key:
110
124
  specification_version: 4
111
125
  summary: Appium made easy
112
126
  test_files: []