testa_appium_driver 0.1.7 → 0.1.8
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/.idea/deployment.xml +1 -1
- data/lib/testa_appium_driver/android/locator/attributes.rb +1 -3
- data/lib/testa_appium_driver/android/locator.rb +1 -1
- data/lib/testa_appium_driver/android/scroll_actions/uiautomator_scroll_actions.rb +1 -0
- data/lib/testa_appium_driver/common/constants.rb +1 -0
- data/lib/testa_appium_driver/common/helpers.rb +27 -0
- data/lib/testa_appium_driver/common/locator/scroll_actions.rb +4 -4
- data/lib/testa_appium_driver/common/locator.rb +33 -7
- data/lib/testa_appium_driver/common/scroll_actions/w3c_scroll_actions.rb +3 -4
- data/lib/testa_appium_driver/common/scroll_actions.rb +5 -14
- data/lib/testa_appium_driver/driver.rb +34 -39
- data/lib/testa_appium_driver/ios/locator.rb +16 -2
- data/lib/testa_appium_driver/ios/type_selectors.rb +36 -2
- data/lib/testa_appium_driver/version.rb +1 -1
- data/testa_appium_driver.iml +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a4f1c169a92dfb2d63ab3dc24f3f427c33ef8d003d3b5708dc7b57ddbf4277e
|
4
|
+
data.tar.gz: 11e34eeeecf99e1d24e55406df81276bc108879909c3588fa8ed90a3f68532fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3673817bd405d0b7f1bb8214ebe2c2dd4a2e472add8fab8e195311469bc0058e66ba7a310547fdaa63601ba2e98f4e8456012fc02757d364d5964567acafd42
|
7
|
+
data.tar.gz: 26c78a2555b1931ee9628b1d0a1543af44da81c97b4da9dab5379653a32189ca271d7e791c0dd5253960638ee91a09f42d535c73e92637c19a0e9450190df969
|
data/.idea/deployment.xml
CHANGED
@@ -7,7 +7,6 @@ module TestaAppiumDriver
|
|
7
7
|
|
8
8
|
@driver = get_driver if self.instance_of?(Selenium::WebDriver::Element)
|
9
9
|
|
10
|
-
@driver.disable_wait_for_idle
|
11
10
|
if elements.kind_of?(Selenium::WebDriver::Element)
|
12
11
|
r = elements.send(:attribute, name.to_s)
|
13
12
|
r = TestaAppiumDriver::Bounds.from_android(r, @driver) if name.to_s == "bounds"
|
@@ -15,7 +14,6 @@ module TestaAppiumDriver
|
|
15
14
|
r = elements.map { |e| e.send(:attribute, name.to_s) }
|
16
15
|
r.map! { |b| TestaAppiumDriver::Bounds.from_android(b, @driver) } if name.to_s == "bounds"
|
17
16
|
end
|
18
|
-
@driver.enable_wait_for_idle
|
19
17
|
r
|
20
18
|
end
|
21
19
|
|
@@ -110,7 +108,7 @@ module TestaAppiumDriver
|
|
110
108
|
children = self.dup.parent.children.execute
|
111
109
|
index = children.index(this)
|
112
110
|
raise "Index not found" if index.nil?
|
113
|
-
index
|
111
|
+
index.to_i
|
114
112
|
end
|
115
113
|
end
|
116
114
|
end
|
@@ -106,7 +106,7 @@ module TestaAppiumDriver
|
|
106
106
|
end
|
107
107
|
|
108
108
|
if is_scrollable_selector?(selectors, single)
|
109
|
-
locator.scrollable_locator =
|
109
|
+
locator.scrollable_locator = locator
|
110
110
|
if selectors[:class] == "android.widget.HorizontalScrollView"
|
111
111
|
locator.scrollable_locator.scroll_orientation = :horizontal
|
112
112
|
else
|
@@ -6,6 +6,7 @@ module TestaAppiumDriver
|
|
6
6
|
def uiautomator_scroll_to_start_or_end(type)
|
7
7
|
|
8
8
|
scrollable_selector = @scrollable.ui_selector(false)
|
9
|
+
puts @scrollable.bounds
|
9
10
|
orientation = @scrollable.scroll_orientation == :vertical ? ".setAsVerticalList()" : ".setAsHorizontalList()"
|
10
11
|
scroll_command = type == :start ? ".scrollToBeginning(#{DEFAULT_UIAUTOMATOR_MAX_SWIPES})" : ".scrollToEnd(#{DEFAULT_UIAUTOMATOR_MAX_SWIPES})"
|
11
12
|
cmd = "new UiScrollable(#{scrollable_selector})#{orientation}#{scroll_command};"
|
@@ -157,6 +157,33 @@ module TestaAppiumDriver
|
|
157
157
|
command
|
158
158
|
end
|
159
159
|
|
160
|
+
|
161
|
+
def hash_to_class_chain(hash, single = true)
|
162
|
+
command = "**/"
|
163
|
+
|
164
|
+
hash[:type] = hash[:class] unless hash[:class].nil?
|
165
|
+
hash[:label] = hash[:text] unless hash[:text].nil?
|
166
|
+
hash[:name] = hash[:id] unless hash[:id].nil?
|
167
|
+
if hash[:type] && hash[:type].kind_of?(String)
|
168
|
+
command = "#{ command }#{hash[:type] }"
|
169
|
+
else
|
170
|
+
command = "#{command}*"
|
171
|
+
end
|
172
|
+
|
173
|
+
command = "#{ command }[`enabled == #{ hash[:enabled] }`]" unless hash[:enabled].nil?
|
174
|
+
command = "#{ command }[`label == \"#{ %(#{hash[:label] }) }\"`]" if hash[:label] && hash[:label].kind_of?(String)
|
175
|
+
command = "#{ command }[`label CONTAINS \"#{ %(#{hash[:label].source }) }\"`]" if hash[:label] && hash[:label].kind_of?(Regexp)
|
176
|
+
command = "#{ command }[`name == \"#{ %(#{hash[:name] }) }\"`]" if hash[:name] && hash[:name].kind_of?(String)
|
177
|
+
command = "#{ command }[`name CONTAINS \"#{ %(#{hash[:name].source }) }\"`]" if hash[:name] && hash[:name].kind_of?(Regexp)
|
178
|
+
command = "#{ command }[`value == \"#{ %(#{hash[:value] }) }\"`]" if hash[:value] && hash[:value].kind_of?(String)
|
179
|
+
command = "#{ command }[`value CONTAINS \"#{ %(#{hash[:value].source }) }\"`]" if hash[:value] && hash[:value].kind_of?(Regexp)
|
180
|
+
command = "#{ command }[`visible == #{ hash[:visible] }`]" unless hash[:visible].nil?
|
181
|
+
|
182
|
+
command += "[1]" if single
|
183
|
+
|
184
|
+
command
|
185
|
+
end
|
186
|
+
|
160
187
|
# check if selectors are for a scrollable element
|
161
188
|
# @param [Boolean] single should the command return first instance or all of matched elements
|
162
189
|
# @param [Hash] selectors for fetching elements
|
@@ -289,7 +289,7 @@ module TestaAppiumDriver
|
|
289
289
|
x = to[:x]
|
290
290
|
y = to[:y]
|
291
291
|
end
|
292
|
-
_drag_to(x, y)
|
292
|
+
_drag_to(bounds.center.x, bounds.center.y, x, y)
|
293
293
|
end
|
294
294
|
|
295
295
|
def drag_by(amount, direction: :top)
|
@@ -308,7 +308,7 @@ module TestaAppiumDriver
|
|
308
308
|
else
|
309
309
|
raise "Unknown direction #{direction}"
|
310
310
|
end
|
311
|
-
_drag_to(x, y)
|
311
|
+
_drag_to(b.center.x, b.center.y, x, y)
|
312
312
|
end
|
313
313
|
|
314
314
|
|
@@ -326,11 +326,11 @@ module TestaAppiumDriver
|
|
326
326
|
deadzone
|
327
327
|
end
|
328
328
|
|
329
|
-
def _drag_to(
|
329
|
+
def _drag_to(x0, y0, x1, y1)
|
330
330
|
sa = ScrollActions.new(@scrollable_locator,
|
331
331
|
locator: self,
|
332
332
|
default_scroll_strategy: @default_scroll_strategy)
|
333
|
-
sa.drag_to(
|
333
|
+
sa.drag_to(x0, y0, x1, y1)
|
334
334
|
self
|
335
335
|
end
|
336
336
|
|
@@ -133,7 +133,7 @@ module TestaAppiumDriver
|
|
133
133
|
|
134
134
|
|
135
135
|
|
136
|
-
r = @driver.execute(@from_element, @single, strategies_and_selectors, skip_cache, ignore_implicit_wait)
|
136
|
+
r = @driver.execute(@from_element, @single, strategies_and_selectors, skip_cache: skip_cache, ignore_implicit_wait: ignore_implicit_wait)
|
137
137
|
r = r[@index_for_multiple] if !@index_for_multiple.nil? && !@single
|
138
138
|
r
|
139
139
|
end
|
@@ -221,13 +221,20 @@ module TestaAppiumDriver
|
|
221
221
|
|
222
222
|
def [](instance)
|
223
223
|
raise "Cannot add index selector to non-Array" if @single
|
224
|
-
if ((@strategy.nil? && !@last_selector_adjacent) || @strategy == FIND_STRATEGY_UIAUTOMATOR) && instance >= 0
|
224
|
+
if ((@strategy.nil? && !@last_selector_adjacent && @driver.device == :android) || @strategy == FIND_STRATEGY_UIAUTOMATOR) && instance >= 0
|
225
225
|
locator = self.dup
|
226
226
|
locator.strategy = FIND_STRATEGY_UIAUTOMATOR
|
227
227
|
locator.ui_selector = "#{@ui_selector}.instance(#{instance})"
|
228
228
|
locator.single = true
|
229
229
|
locator.can_use_id_strategy = false
|
230
230
|
locator
|
231
|
+
elsif (@driver.device == :ios && !@last_selector_adjacent && @strategy.nil?) || @strategy == FIND_STRATEGY_CLASS_CHAIN
|
232
|
+
locator = self.dup
|
233
|
+
locator.strategy = FIND_STRATEGY_CLASS_CHAIN
|
234
|
+
locator.class_chain_selector += "[#{instance + 1}]"
|
235
|
+
locator.single = true
|
236
|
+
locator.can_use_id_strategy = false
|
237
|
+
locator
|
231
238
|
else
|
232
239
|
from_element = self.dup
|
233
240
|
from_element.index_for_multiple = instance
|
@@ -306,7 +313,15 @@ module TestaAppiumDriver
|
|
306
313
|
end
|
307
314
|
|
308
315
|
def click
|
309
|
-
|
316
|
+
if @driver.device == :android
|
317
|
+
perform_driver_method(:click)
|
318
|
+
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
|
324
|
+
end
|
310
325
|
end
|
311
326
|
|
312
327
|
def send_key(*args)
|
@@ -336,15 +351,20 @@ module TestaAppiumDriver
|
|
336
351
|
# @return [TestaAppiumDriver::Locator]
|
337
352
|
def children
|
338
353
|
raise "Cannot add children selector to array" unless @single
|
339
|
-
raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "children") if @strategy != FIND_STRATEGY_XPATH && !@strategy.nil?
|
354
|
+
raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "children") if @strategy != FIND_STRATEGY_XPATH && @strategy != FIND_STRATEGY_CLASS_CHAIN && !@strategy.nil?
|
340
355
|
|
341
356
|
locator = self.dup
|
342
|
-
locator.strategy = FIND_STRATEGY_XPATH
|
343
357
|
locator.strategy_reason = "children"
|
344
358
|
locator.xpath_selector += "/*"
|
345
359
|
locator.single = false
|
346
360
|
locator.last_selector_adjacent = true
|
347
361
|
locator.can_use_id_strategy = false
|
362
|
+
|
363
|
+
if @driver.device == :android
|
364
|
+
locator.strategy = FIND_STRATEGY_XPATH
|
365
|
+
else
|
366
|
+
locator.class_chain_selector += "/*"
|
367
|
+
end
|
348
368
|
locator
|
349
369
|
end
|
350
370
|
|
@@ -353,14 +373,20 @@ module TestaAppiumDriver
|
|
353
373
|
# @return [TestaAppiumDriver::Locator]
|
354
374
|
def child
|
355
375
|
raise "Cannot add children selector to array" unless @single
|
356
|
-
raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "child") if @strategy != FIND_STRATEGY_XPATH && !@strategy.nil?
|
376
|
+
raise StrategyMixException.new(@strategy, @strategy_reason, FIND_STRATEGY_XPATH, "child") if @strategy != FIND_STRATEGY_XPATH && @strategy != FIND_STRATEGY_CLASS_CHAIN && !@strategy.nil?
|
357
377
|
|
358
378
|
locator = self.dup
|
359
|
-
|
379
|
+
|
360
380
|
locator.strategy_reason = "child"
|
361
381
|
locator.xpath_selector += "/*[1]"
|
362
382
|
locator.single = true
|
363
383
|
locator.can_use_id_strategy = false
|
384
|
+
|
385
|
+
if @driver.device == :android
|
386
|
+
locator.strategy = FIND_STRATEGY_XPATH
|
387
|
+
else
|
388
|
+
locator.class_chain_selector += "/*[1]"
|
389
|
+
end
|
364
390
|
locator
|
365
391
|
end
|
366
392
|
|
@@ -23,6 +23,7 @@ module TestaAppiumDriver
|
|
23
23
|
until is_end_of_scroll?
|
24
24
|
matches = @locator.execute(skip_cache: true)
|
25
25
|
matches.each_with_index do |m|
|
26
|
+
next if elements.include?(m)
|
26
27
|
elements << m
|
27
28
|
if block_given? # block is given
|
28
29
|
block.call(m) # use call to execute the block
|
@@ -228,10 +229,8 @@ module TestaAppiumDriver
|
|
228
229
|
|
229
230
|
|
230
231
|
|
231
|
-
def w3c_drag_to(
|
232
|
-
x0
|
233
|
-
y0 = @bounds.center.y
|
234
|
-
w3c_action(x0, y0, x, y, SCROLL_ACTION_TYPE_DRAG)
|
232
|
+
def w3c_drag_to(x0, y0, x1, y1)
|
233
|
+
w3c_action(x0, y0, x1, y1, SCROLL_ACTION_TYPE_DRAG)
|
235
234
|
end
|
236
235
|
|
237
236
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require_relative 'scroll_actions/json_wire_scroll_actions'
|
2
2
|
require_relative 'scroll_actions/w3c_scroll_actions'
|
3
3
|
|
4
|
-
|
5
4
|
module TestaAppiumDriver
|
6
5
|
|
7
6
|
# Class for handling scroll actions
|
@@ -21,7 +20,6 @@ module TestaAppiumDriver
|
|
21
20
|
@default_scroll_strategy = params[:default_scroll_strategy]
|
22
21
|
@driver = @locator.driver
|
23
22
|
|
24
|
-
|
25
23
|
if @scrollable.nil?
|
26
24
|
# if we dont have a scrollable element or if we do have it, but it is not compatible with uiautomator
|
27
25
|
# then find first scrollable in document
|
@@ -30,16 +28,14 @@ module TestaAppiumDriver
|
|
30
28
|
|
31
29
|
@strategy = nil
|
32
30
|
if @scrollable.strategy == FIND_STRATEGY_XPATH || # uiautomator cannot resolve scrollable from a xpath locator
|
33
|
-
|
34
|
-
|
31
|
+
!@deadzone.nil? ||
|
32
|
+
!@scrollable.from_element.instance_of?(TestaAppiumDriver::Driver) # uiautomator cannot resolve nested scrollable
|
35
33
|
@strategy = SCROLL_STRATEGY_W3C
|
36
34
|
end
|
37
35
|
|
38
|
-
|
39
36
|
@bounds = @scrollable.bounds
|
40
37
|
end
|
41
38
|
|
42
|
-
|
43
39
|
def align(with, scroll_to_find)
|
44
40
|
w3c_align(with, scroll_to_find)
|
45
41
|
@locator
|
@@ -66,7 +62,6 @@ module TestaAppiumDriver
|
|
66
62
|
w3c_each(:left, &block)
|
67
63
|
end
|
68
64
|
|
69
|
-
|
70
65
|
def resolve_strategy
|
71
66
|
if @strategy.nil?
|
72
67
|
@default_scroll_strategy
|
@@ -75,7 +70,6 @@ module TestaAppiumDriver
|
|
75
70
|
end
|
76
71
|
end
|
77
72
|
|
78
|
-
|
79
73
|
def scroll_to
|
80
74
|
if @locator.strategy != FIND_STRATEGY_XPATH && resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
81
75
|
uiautomator_scroll_to
|
@@ -116,7 +110,6 @@ module TestaAppiumDriver
|
|
116
110
|
end
|
117
111
|
end
|
118
112
|
|
119
|
-
|
120
113
|
def page_down
|
121
114
|
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
122
115
|
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :down)
|
@@ -149,10 +142,10 @@ module TestaAppiumDriver
|
|
149
142
|
end
|
150
143
|
end
|
151
144
|
|
152
|
-
|
153
145
|
def scroll_to_start
|
154
146
|
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
155
147
|
uiautomator_scroll_to_start_or_end(:start)
|
148
|
+
|
156
149
|
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
157
150
|
w3c_scroll_to_start_or_end(:start)
|
158
151
|
end
|
@@ -198,11 +191,10 @@ module TestaAppiumDriver
|
|
198
191
|
end
|
199
192
|
end
|
200
193
|
|
201
|
-
def drag_to(
|
202
|
-
w3c_drag_to(
|
194
|
+
def drag_to(x0, y0, x1, y1)
|
195
|
+
w3c_drag_to(x0, y0, x1, y1)
|
203
196
|
end
|
204
197
|
|
205
|
-
|
206
198
|
private
|
207
199
|
|
208
200
|
def is_end_of_scroll?
|
@@ -211,7 +203,6 @@ module TestaAppiumDriver
|
|
211
203
|
old_elements == @previous_elements
|
212
204
|
end
|
213
205
|
|
214
|
-
|
215
206
|
def default_deadzone!
|
216
207
|
@deadzone = {} if @deadzone.nil?
|
217
208
|
if @deadzone[:top].nil?
|
@@ -29,9 +29,6 @@ module TestaAppiumDriver
|
|
29
29
|
def initialize(opts = {})
|
30
30
|
@testa_opts = opts[:testa_appium_driver] || {}
|
31
31
|
|
32
|
-
@wait_for_idle_disabled = false
|
33
|
-
@implicit_wait_disabled = false
|
34
|
-
|
35
32
|
core = Appium::Core.for(opts)
|
36
33
|
extend_for(core.device, core.automation_name)
|
37
34
|
@device = core.device
|
@@ -43,6 +40,9 @@ module TestaAppiumDriver
|
|
43
40
|
invalidate_cache
|
44
41
|
|
45
42
|
|
43
|
+
disable_wait_for_idle
|
44
|
+
disable_implicit_wait
|
45
|
+
|
46
46
|
Selenium::WebDriver::Element.set_driver(self, opts[:caps][:udid])
|
47
47
|
end
|
48
48
|
|
@@ -69,11 +69,9 @@ module TestaAppiumDriver
|
|
69
69
|
# @param [Array<Hash>] strategies_and_selectors array of usable strategies and selectors
|
70
70
|
# @param [Boolean] skip_cache to skip checking and storing cache
|
71
71
|
# @return [Selenium::WebDriver::Element, Array] element is returned if single is true, array otherwise
|
72
|
-
def execute(from_element, single, strategies_and_selectors, skip_cache
|
72
|
+
def execute(from_element, single, strategies_and_selectors, skip_cache: false, ignore_implicit_wait: false)
|
73
73
|
|
74
74
|
# if user wants to wait for element to exist, he can use wait_until_present
|
75
|
-
disable_wait_for_idle
|
76
|
-
disable_implicit_wait
|
77
75
|
start_time = Time.now.to_f
|
78
76
|
ss_index = 0
|
79
77
|
|
@@ -132,9 +130,6 @@ module TestaAppiumDriver
|
|
132
130
|
else
|
133
131
|
raise e
|
134
132
|
end
|
135
|
-
ensure
|
136
|
-
enable_implicit_wait
|
137
|
-
enable_wait_for_idle
|
138
133
|
end
|
139
134
|
|
140
135
|
execute_result
|
@@ -151,43 +146,23 @@ module TestaAppiumDriver
|
|
151
146
|
|
152
147
|
# disables implicit wait
|
153
148
|
def disable_implicit_wait
|
154
|
-
|
155
|
-
@implicit_wait_ms = @
|
149
|
+
@implicit_wait_ms = @driver.get_timeouts["implicit"].to_i
|
150
|
+
@implicit_wait_ms = @implicit_wait_ms/1000 if @implicit_wait_ms > 100000
|
156
151
|
@implicit_wait_uiautomator_ms = @driver.get_settings["waitForSelectorTimeout"]
|
157
152
|
@driver.manage.timeouts.implicit_wait = 0
|
158
|
-
@driver.update_settings({waitForSelectorTimeout:
|
159
|
-
@implicit_wait_disabled = true
|
160
|
-
end
|
153
|
+
@driver.update_settings({waitForSelectorTimeout: 1})
|
161
154
|
end
|
162
155
|
|
163
|
-
# enables implicit wait, can be called only after disabling implicit wait
|
164
|
-
def enable_implicit_wait
|
165
|
-
raise "Implicit wait is not disabled" unless @implicit_wait_disabled
|
166
|
-
# get_timeouts always returns in milliseconds, but we should set in seconds
|
167
|
-
@driver.manage.timeouts.implicit_wait = @implicit_wait_ms / 1000
|
168
|
-
@driver.update_settings({waitForSelectorTimeout: @implicit_wait_uiautomator_ms})
|
169
|
-
@implicit_wait_disabled = false
|
170
|
-
end
|
171
156
|
|
172
157
|
# disables wait for idle, only executed for android devices
|
173
158
|
def disable_wait_for_idle
|
174
|
-
unless @wait_for_idle_disabled
|
175
|
-
if @device == :android
|
176
|
-
@wait_for_idle_timeout = @driver.settings.get["waitForIdleTimeout"]
|
177
|
-
@driver.update_settings({waitForIdleTimeout: 0})
|
178
|
-
end
|
179
|
-
@wait_for_idle_disabled = true
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
# enables wait for idle, only executed for android devices
|
184
|
-
def enable_wait_for_idle
|
185
159
|
if @device == :android
|
186
|
-
|
187
|
-
@driver.update_settings({waitForIdleTimeout:
|
160
|
+
@wait_for_idle_timeout = @driver.settings.get["waitForIdleTimeout"]
|
161
|
+
@driver.update_settings({waitForIdleTimeout: 1})
|
188
162
|
end
|
189
163
|
end
|
190
164
|
|
165
|
+
|
191
166
|
def set_find_by_image_settings(settings)
|
192
167
|
settings.delete(:image)
|
193
168
|
@default_find_image_settings = {}
|
@@ -233,6 +208,30 @@ module TestaAppiumDriver
|
|
233
208
|
@driver.hide_keyboard
|
234
209
|
end
|
235
210
|
|
211
|
+
def tab_key
|
212
|
+
@driver.press_keycode(61)
|
213
|
+
end
|
214
|
+
|
215
|
+
def dpad_up_key
|
216
|
+
@driver.press_keycode(19)
|
217
|
+
end
|
218
|
+
|
219
|
+
def dpad_down_key
|
220
|
+
@driver.press_keycode(20)
|
221
|
+
end
|
222
|
+
|
223
|
+
def dpad_right_key
|
224
|
+
@driver.press_keycode(22)
|
225
|
+
end
|
226
|
+
|
227
|
+
def dpad_left_key
|
228
|
+
@driver.press_keycode(23)
|
229
|
+
end
|
230
|
+
|
231
|
+
def enter_key
|
232
|
+
@driver.press_keycode(66)
|
233
|
+
end
|
234
|
+
|
236
235
|
def press_keycode(code)
|
237
236
|
@driver.press_keycode(code)
|
238
237
|
end
|
@@ -246,11 +245,7 @@ module TestaAppiumDriver
|
|
246
245
|
|
247
246
|
# @return [Array<Selenium::WebDriver::Element] array of 2 elements, the first element without children and the last element without children in the current page
|
248
247
|
def first_and_last_leaf(from_element = @driver)
|
249
|
-
disable_wait_for_idle
|
250
|
-
disable_implicit_wait
|
251
248
|
elements = from_element.find_elements(xpath: "//*[not(*)]")
|
252
|
-
enable_implicit_wait
|
253
|
-
enable_wait_for_idle
|
254
249
|
return nil if elements.count == 0
|
255
250
|
[elements[0], elements[-1]]
|
256
251
|
end
|
@@ -3,6 +3,7 @@ require_relative 'locator/attributes'
|
|
3
3
|
module TestaAppiumDriver
|
4
4
|
class Locator
|
5
5
|
include TypeSelectors
|
6
|
+
attr_accessor :class_chain_selector
|
6
7
|
|
7
8
|
def init(params, selectors, single)
|
8
9
|
if is_scrollable_selector?(selectors, single)
|
@@ -19,6 +20,9 @@ module TestaAppiumDriver
|
|
19
20
|
params[:scrollable_locator] = self.dup
|
20
21
|
end
|
21
22
|
|
23
|
+
@class_chain_selector = hash_to_class_chain(selectors, single)
|
24
|
+
|
25
|
+
|
22
26
|
@scrollable_locator = params[:scrollable_locator] if params[:scrollable_locator]
|
23
27
|
end
|
24
28
|
|
@@ -29,7 +33,7 @@ module TestaAppiumDriver
|
|
29
33
|
if @can_use_id_strategy
|
30
34
|
ss.push({"#{FIND_STRATEGY_NAME}": @can_use_id_strategy})
|
31
35
|
end
|
32
|
-
|
36
|
+
ss.push({"#{FIND_STRATEGY_CLASS_CHAIN}": @class_chain_selector}) if @strategy.nil? || @strategy == FIND_STRATEGY_CLASS_CHAIN
|
33
37
|
ss.push({"#{FIND_STRATEGY_XPATH}": @xpath_selector}) if @strategy.nil? || @strategy == FIND_STRATEGY_XPATH
|
34
38
|
ss.push({"#{FIND_STRATEGY_IMAGE}": @image_selector}) if @strategy == FIND_STRATEGY_IMAGE
|
35
39
|
ss
|
@@ -45,13 +49,23 @@ module TestaAppiumDriver
|
|
45
49
|
|
46
50
|
locator = self.dup
|
47
51
|
add_xpath_child_selectors(locator, selectors, single)
|
52
|
+
if @strategy.nil? || @strategy == FIND_STRATEGY_CLASS_CHAIN
|
53
|
+
add_class_chain_child_selectors(locator, selectors, single)
|
54
|
+
end
|
55
|
+
|
48
56
|
if is_scrollable_selector?(selectors, single)
|
49
57
|
locator.scrollable_locator.scroll_orientation = :vertical
|
50
|
-
locator.scrollable_locator =
|
58
|
+
locator.scrollable_locator = locator
|
51
59
|
end
|
52
60
|
|
53
61
|
locator.last_selector_adjacent = false
|
54
62
|
locator
|
55
63
|
end
|
64
|
+
|
65
|
+
|
66
|
+
def add_class_chain_child_selectors(locator, selectors, single)
|
67
|
+
locator.single = false unless single # switching from single result to multiple
|
68
|
+
locator.class_chain_selector += "/" + hash_to_class_chain(selectors, single)
|
69
|
+
end
|
56
70
|
end
|
57
71
|
end
|
@@ -5,10 +5,15 @@ module TestaAppiumDriver
|
|
5
5
|
# @return [TestaAppiumDriver::Locator]
|
6
6
|
def add_selector(*args, &block)
|
7
7
|
# if class selector is executed from driver, create new locator instance
|
8
|
-
if self.kind_of?(TestaAppiumDriver::Driver) || self.
|
8
|
+
if self.kind_of?(TestaAppiumDriver::Driver) || self.instance_of?(Selenium::WebDriver::Element)
|
9
9
|
args.last[:default_find_strategy] = @default_find_strategy
|
10
10
|
args.last[:default_scroll_strategy] = @default_scroll_strategy
|
11
|
-
|
11
|
+
if self.instance_of?(Selenium::WebDriver::Element)
|
12
|
+
driver = self.get_driver
|
13
|
+
else
|
14
|
+
driver = self
|
15
|
+
end
|
16
|
+
Locator.new(driver, self, *args)
|
12
17
|
else
|
13
18
|
# class selector is executed from locator, just add child selector criteria
|
14
19
|
self.add_child_selector(*args)
|
@@ -150,5 +155,34 @@ module TestaAppiumDriver
|
|
150
155
|
params[:single] = false
|
151
156
|
add_selector(params)
|
152
157
|
end
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
# @return [TestaAppiumDriver::Locator]
|
162
|
+
def text_field(params = {})
|
163
|
+
params[:type] = "XCUIElementTypeTextField"
|
164
|
+
add_selector(params)
|
165
|
+
end
|
166
|
+
|
167
|
+
# @return [TestaAppiumDriver::Locator]
|
168
|
+
def text_fields(params = {})
|
169
|
+
params[:type] = "XCUIElementTypeTextField"
|
170
|
+
params[:single] = false
|
171
|
+
add_selector(params)
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
# @return [TestaAppiumDriver::Locator]
|
176
|
+
def secure_text_field(params = {})
|
177
|
+
params[:type] = "XCUIElementTypeSecureTextField"
|
178
|
+
add_selector(params)
|
179
|
+
end
|
180
|
+
|
181
|
+
# @return [TestaAppiumDriver::Locator]
|
182
|
+
def secure_text_fields(params = {})
|
183
|
+
params[:type] = "XCUIElementTypeSecureTextField"
|
184
|
+
params[:single] = false
|
185
|
+
add_selector(params)
|
186
|
+
end
|
153
187
|
end
|
154
188
|
end
|
data/testa_appium_driver.iml
CHANGED
@@ -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.
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, 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.
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="json (v2.1.0, 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.
|
32
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.
|
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" />
|
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.
|
4
|
+
version: 0.1.8
|
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
|
+
date: 2021-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appium_lib_core
|