testa_appium_driver 0.1.11 → 0.1.12
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/.gitignore +15 -15
- data/.idea/deployment.xml +21 -21
- data/.idea/inspectionProfiles/Project_Default.xml +8 -8
- data/.idea/misc.xml +5 -5
- data/.idea/modules.xml +7 -7
- data/.idea/runConfigurations/Android_Test.xml +41 -41
- data/.idea/runConfigurations.xml +9 -9
- data/.idea/sshConfigs.xml +12 -12
- data/.idea/vcs.xml +5 -5
- data/.idea/webServers.xml +20 -20
- data/.rspec +3 -3
- data/.rubocop.yml +13 -13
- data/CHANGELOG.md +5 -5
- data/CODE_OF_CONDUCT.md +102 -102
- data/Gemfile +12 -12
- data/LICENSE.txt +21 -21
- data/README.md +378 -378
- data/Rakefile +12 -12
- data/bin/console +17 -17
- data/bin/setup +8 -8
- data/lib/testa_appium_driver/android/class_selectors.rb +437 -437
- data/lib/testa_appium_driver/android/driver.rb +69 -69
- data/lib/testa_appium_driver/android/locator/attributes.rb +113 -113
- data/lib/testa_appium_driver/android/locator.rb +141 -141
- data/lib/testa_appium_driver/android/scroll_actions/uiautomator_scroll_actions.rb +61 -61
- data/lib/testa_appium_driver/android/selenium_element.rb +7 -7
- data/lib/testa_appium_driver/common/bounds.rb +149 -149
- data/lib/testa_appium_driver/common/constants.rb +36 -36
- data/lib/testa_appium_driver/common/exceptions/strategy_mix_exception.rb +11 -11
- data/lib/testa_appium_driver/common/helpers.rb +270 -270
- data/lib/testa_appium_driver/common/locator/scroll_actions.rb +397 -397
- data/lib/testa_appium_driver/common/locator.rb +610 -610
- data/lib/testa_appium_driver/common/scroll_actions/json_wire_scroll_actions.rb +3 -3
- data/lib/testa_appium_driver/common/scroll_actions/w3c_scroll_actions.rb +237 -237
- data/lib/testa_appium_driver/common/scroll_actions.rb +246 -246
- data/lib/testa_appium_driver/common/selenium_element.rb +19 -19
- data/lib/testa_appium_driver/driver.rb +312 -312
- data/lib/testa_appium_driver/ios/driver.rb +48 -48
- data/lib/testa_appium_driver/ios/locator/attributes.rb +80 -80
- data/lib/testa_appium_driver/ios/locator.rb +70 -70
- data/lib/testa_appium_driver/ios/selenium_element.rb +6 -6
- data/lib/testa_appium_driver/ios/type_selectors.rb +187 -187
- data/lib/testa_appium_driver/version.rb +5 -5
- data/lib/testa_appium_driver.rb +6 -6
- data/testa_appium_driver.gemspec +41 -41
- data/testa_appium_driver.iml +27 -78
- metadata +3 -3
@@ -1,247 +1,247 @@
|
|
1
|
-
require_relative 'scroll_actions/json_wire_scroll_actions'
|
2
|
-
require_relative 'scroll_actions/w3c_scroll_actions'
|
3
|
-
|
4
|
-
module TestaAppiumDriver
|
5
|
-
|
6
|
-
# Class for handling scroll actions
|
7
|
-
class ScrollActions
|
8
|
-
# @param [TestaAppiumDriver::Locator, nil] scrollable container that will be used to determine the bounds for scrolling
|
9
|
-
# @param [Hash] params
|
10
|
-
# acceptable params
|
11
|
-
# - locator - element that should be found with scrolling actions
|
12
|
-
# - deadzone - [Hash] that stores top, bottom, left and right deadzone values. If deadzone[:top] is 200 then 200px from top of the scrollable container will not be used for scrolling
|
13
|
-
# - max_scrolls - [Integer] maximum number of scrolls before exception is thrown
|
14
|
-
# - default_scroll_strategy - defines which scroll strategy will be used if a scroll action is valid for multiple strategies
|
15
|
-
def initialize(scrollable, params = {})
|
16
|
-
@scrollable = scrollable
|
17
|
-
@locator = params[:locator]
|
18
|
-
@deadzone = params[:deadzone]
|
19
|
-
@max_scrolls = params[:max_scrolls]
|
20
|
-
@default_scroll_strategy = params[:default_scroll_strategy]
|
21
|
-
@driver = @locator.driver
|
22
|
-
|
23
|
-
if @scrollable.nil?
|
24
|
-
# if we dont have a scrollable element or if we do have it, but it is not compatible with uiautomator
|
25
|
-
# then find first scrollable in document
|
26
|
-
@scrollable = @driver.scrollable
|
27
|
-
end
|
28
|
-
|
29
|
-
@strategy = nil
|
30
|
-
if @scrollable.strategy == FIND_STRATEGY_XPATH || # uiautomator cannot resolve scrollable from a xpath locator
|
31
|
-
!@deadzone.nil? ||
|
32
|
-
!@scrollable.from_element.instance_of?(TestaAppiumDriver::Driver) # uiautomator cannot resolve nested scrollable
|
33
|
-
@strategy = SCROLL_STRATEGY_W3C
|
34
|
-
end
|
35
|
-
|
36
|
-
@bounds = @scrollable.bounds
|
37
|
-
end
|
38
|
-
|
39
|
-
def align(with, scroll_to_find)
|
40
|
-
w3c_align(with, scroll_to_find)
|
41
|
-
@locator
|
42
|
-
end
|
43
|
-
|
44
|
-
# @return [Array]
|
45
|
-
def
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
def
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
def
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
def
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
def
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
def resolve_strategy
|
66
|
-
if @strategy.nil?
|
67
|
-
@default_scroll_strategy
|
68
|
-
else
|
69
|
-
@strategy
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def scroll_to
|
74
|
-
if @locator.strategy != FIND_STRATEGY_XPATH && resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
75
|
-
uiautomator_scroll_to
|
76
|
-
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
77
|
-
w3c_scroll_to(nil)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def scroll_down_to
|
82
|
-
w3c_scroll_to(:down)
|
83
|
-
end
|
84
|
-
|
85
|
-
def scroll_up_to
|
86
|
-
w3c_scroll_to(:up)
|
87
|
-
end
|
88
|
-
|
89
|
-
def scroll_right_to
|
90
|
-
w3c_scroll_to(:right)
|
91
|
-
end
|
92
|
-
|
93
|
-
def scroll_left_to
|
94
|
-
w3c_scroll_to(:left)
|
95
|
-
end
|
96
|
-
|
97
|
-
def page_next
|
98
|
-
if @scrollable.scroll_orientation == :vertical
|
99
|
-
page_down
|
100
|
-
else
|
101
|
-
page_left
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def page_back
|
106
|
-
if @scrollable.scroll_orientation == :vertical
|
107
|
-
page_up
|
108
|
-
else
|
109
|
-
page_right
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def page_down
|
114
|
-
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
115
|
-
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :down)
|
116
|
-
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
117
|
-
w3c_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :down)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def page_right
|
122
|
-
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
123
|
-
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :right)
|
124
|
-
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
125
|
-
w3c_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :right)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def page_up
|
130
|
-
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
131
|
-
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :up)
|
132
|
-
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
133
|
-
w3c_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :up)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def page_left
|
138
|
-
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
139
|
-
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :left)
|
140
|
-
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
141
|
-
w3c_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :left)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
def scroll_to_start
|
146
|
-
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
147
|
-
uiautomator_scroll_to_start_or_end(:start)
|
148
|
-
|
149
|
-
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
150
|
-
w3c_scroll_to_start_or_end(:start)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def scroll_to_end
|
155
|
-
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
156
|
-
uiautomator_scroll_to_start_or_end(:end)
|
157
|
-
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
158
|
-
w3c_scroll_to_start_or_end(:end)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
def fling_down
|
163
|
-
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
164
|
-
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_FLING, :down)
|
165
|
-
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
166
|
-
w3c_page_or_fling(SCROLL_ACTION_TYPE_FLING, :down)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def fling_right
|
171
|
-
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
172
|
-
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_FLING, :right)
|
173
|
-
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
174
|
-
w3c_page_or_fling(SCROLL_ACTION_TYPE_FLING, :right)
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
def fling_up
|
179
|
-
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
180
|
-
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_FLING, :up)
|
181
|
-
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
182
|
-
w3c_page_or_fling(SCROLL_ACTION_TYPE_FLING, :up)
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
def fling_left
|
187
|
-
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
188
|
-
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_FLING, :left)
|
189
|
-
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
190
|
-
w3c_page_or_fling(SCROLL_ACTION_TYPE_FLING, :left)
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
def drag_to(x0, y0, x1, y1)
|
195
|
-
w3c_drag_to(x0, y0, x1, y1)
|
196
|
-
end
|
197
|
-
|
198
|
-
private
|
199
|
-
|
200
|
-
def is_end_of_scroll?
|
201
|
-
old_elements = @previous_elements
|
202
|
-
@previous_elements = @scrollable.first_and_last_leaf
|
203
|
-
old_elements == @previous_elements
|
204
|
-
end
|
205
|
-
|
206
|
-
def default_deadzone!
|
207
|
-
@deadzone = {} if @deadzone.nil?
|
208
|
-
if @deadzone[:top].nil?
|
209
|
-
@deadzone[:top] = 1
|
210
|
-
else
|
211
|
-
@deadzone[:top] = @deadzone[:top].to_f
|
212
|
-
end
|
213
|
-
if @deadzone[:bottom].nil?
|
214
|
-
@deadzone[:bottom] = 1
|
215
|
-
else
|
216
|
-
@deadzone[:bottom] = @deadzone[:bottom].to_f
|
217
|
-
end
|
218
|
-
if @deadzone[:right].nil?
|
219
|
-
@deadzone[:right] = 1
|
220
|
-
else
|
221
|
-
@deadzone[:right] = @deadzone[:right].to_f
|
222
|
-
end
|
223
|
-
if @deadzone[:left].nil?
|
224
|
-
@deadzone[:left] = 1
|
225
|
-
else
|
226
|
-
@deadzone[:left] = @deadzone[:left].to_f
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
def is_aligned?(with, element)
|
231
|
-
align_bounds = @locator.bounds(force_cache_element: element)
|
232
|
-
case with
|
233
|
-
when :top
|
234
|
-
@align_offset = align_bounds.top_left.y - @bounds.top_left.y + @deadzone[:top]
|
235
|
-
when :bottom
|
236
|
-
@align_offset = @bounds.bottom_right.y - @deadzone[:bottom] - align_bounds.bottom_right.y
|
237
|
-
when :right
|
238
|
-
@align_offset = @bounds.bottom_right.x - @deadzone[:right] - align_bounds.bottom_right.x
|
239
|
-
when :left
|
240
|
-
@align_offset = align_bounds.top_left.x - @bounds.top_left.x + @deadzone[:left]
|
241
|
-
else
|
242
|
-
raise "Unsupported align with option: #{with}"
|
243
|
-
end
|
244
|
-
@align_offset < SCROLL_ALIGNMENT_THRESHOLD
|
245
|
-
end
|
246
|
-
end
|
1
|
+
require_relative 'scroll_actions/json_wire_scroll_actions'
|
2
|
+
require_relative 'scroll_actions/w3c_scroll_actions'
|
3
|
+
|
4
|
+
module TestaAppiumDriver
|
5
|
+
|
6
|
+
# Class for handling scroll actions
|
7
|
+
class ScrollActions
|
8
|
+
# @param [TestaAppiumDriver::Locator, nil] scrollable container that will be used to determine the bounds for scrolling
|
9
|
+
# @param [Hash] params
|
10
|
+
# acceptable params
|
11
|
+
# - locator - element that should be found with scrolling actions
|
12
|
+
# - deadzone - [Hash] that stores top, bottom, left and right deadzone values. If deadzone[:top] is 200 then 200px from top of the scrollable container will not be used for scrolling
|
13
|
+
# - max_scrolls - [Integer] maximum number of scrolls before exception is thrown
|
14
|
+
# - default_scroll_strategy - defines which scroll strategy will be used if a scroll action is valid for multiple strategies
|
15
|
+
def initialize(scrollable, params = {})
|
16
|
+
@scrollable = scrollable
|
17
|
+
@locator = params[:locator]
|
18
|
+
@deadzone = params[:deadzone]
|
19
|
+
@max_scrolls = params[:max_scrolls]
|
20
|
+
@default_scroll_strategy = params[:default_scroll_strategy]
|
21
|
+
@driver = @locator.driver
|
22
|
+
|
23
|
+
if @scrollable.nil?
|
24
|
+
# if we dont have a scrollable element or if we do have it, but it is not compatible with uiautomator
|
25
|
+
# then find first scrollable in document
|
26
|
+
@scrollable = @driver.scrollable
|
27
|
+
end
|
28
|
+
|
29
|
+
@strategy = nil
|
30
|
+
if @scrollable.strategy == FIND_STRATEGY_XPATH || # uiautomator cannot resolve scrollable from a xpath locator
|
31
|
+
!@deadzone.nil? ||
|
32
|
+
!@scrollable.from_element.instance_of?(TestaAppiumDriver::Driver) # uiautomator cannot resolve nested scrollable
|
33
|
+
@strategy = SCROLL_STRATEGY_W3C
|
34
|
+
end
|
35
|
+
|
36
|
+
@bounds = @scrollable.bounds
|
37
|
+
end
|
38
|
+
|
39
|
+
def align(with, scroll_to_find)
|
40
|
+
w3c_align(with, scroll_to_find)
|
41
|
+
@locator
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [Array]
|
45
|
+
def scroll_each(&block)
|
46
|
+
w3c_scroll_each(nil, &block)
|
47
|
+
end
|
48
|
+
|
49
|
+
def scroll_each_down(&block)
|
50
|
+
w3c_scroll_each(:down, &block)
|
51
|
+
end
|
52
|
+
|
53
|
+
def scroll_each_up(&block)
|
54
|
+
w3c_scroll_each(:up, &block)
|
55
|
+
end
|
56
|
+
|
57
|
+
def scroll_each_right(&block)
|
58
|
+
w3c_scroll_each(:right, &block)
|
59
|
+
end
|
60
|
+
|
61
|
+
def scroll_each_left(&block)
|
62
|
+
w3c_scroll_each(:left, &block)
|
63
|
+
end
|
64
|
+
|
65
|
+
def resolve_strategy
|
66
|
+
if @strategy.nil?
|
67
|
+
@default_scroll_strategy
|
68
|
+
else
|
69
|
+
@strategy
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def scroll_to
|
74
|
+
if @locator.strategy != FIND_STRATEGY_XPATH && resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
75
|
+
uiautomator_scroll_to
|
76
|
+
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
77
|
+
w3c_scroll_to(nil)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def scroll_down_to
|
82
|
+
w3c_scroll_to(:down)
|
83
|
+
end
|
84
|
+
|
85
|
+
def scroll_up_to
|
86
|
+
w3c_scroll_to(:up)
|
87
|
+
end
|
88
|
+
|
89
|
+
def scroll_right_to
|
90
|
+
w3c_scroll_to(:right)
|
91
|
+
end
|
92
|
+
|
93
|
+
def scroll_left_to
|
94
|
+
w3c_scroll_to(:left)
|
95
|
+
end
|
96
|
+
|
97
|
+
def page_next
|
98
|
+
if @scrollable.scroll_orientation == :vertical
|
99
|
+
page_down
|
100
|
+
else
|
101
|
+
page_left
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def page_back
|
106
|
+
if @scrollable.scroll_orientation == :vertical
|
107
|
+
page_up
|
108
|
+
else
|
109
|
+
page_right
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def page_down
|
114
|
+
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
115
|
+
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :down)
|
116
|
+
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
117
|
+
w3c_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :down)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def page_right
|
122
|
+
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
123
|
+
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :right)
|
124
|
+
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
125
|
+
w3c_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :right)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def page_up
|
130
|
+
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
131
|
+
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :up)
|
132
|
+
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
133
|
+
w3c_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :up)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def page_left
|
138
|
+
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
139
|
+
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :left)
|
140
|
+
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
141
|
+
w3c_page_or_fling(SCROLL_ACTION_TYPE_SCROLL, :left)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def scroll_to_start
|
146
|
+
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
147
|
+
uiautomator_scroll_to_start_or_end(:start)
|
148
|
+
|
149
|
+
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
150
|
+
w3c_scroll_to_start_or_end(:start)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def scroll_to_end
|
155
|
+
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
156
|
+
uiautomator_scroll_to_start_or_end(:end)
|
157
|
+
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
158
|
+
w3c_scroll_to_start_or_end(:end)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def fling_down
|
163
|
+
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
164
|
+
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_FLING, :down)
|
165
|
+
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
166
|
+
w3c_page_or_fling(SCROLL_ACTION_TYPE_FLING, :down)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def fling_right
|
171
|
+
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
172
|
+
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_FLING, :right)
|
173
|
+
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
174
|
+
w3c_page_or_fling(SCROLL_ACTION_TYPE_FLING, :right)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def fling_up
|
179
|
+
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
180
|
+
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_FLING, :up)
|
181
|
+
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
182
|
+
w3c_page_or_fling(SCROLL_ACTION_TYPE_FLING, :up)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def fling_left
|
187
|
+
if resolve_strategy == SCROLL_STRATEGY_UIAUTOMATOR
|
188
|
+
uiautomator_page_or_fling(SCROLL_ACTION_TYPE_FLING, :left)
|
189
|
+
elsif resolve_strategy == SCROLL_STRATEGY_W3C
|
190
|
+
w3c_page_or_fling(SCROLL_ACTION_TYPE_FLING, :left)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def drag_to(x0, y0, x1, y1)
|
195
|
+
w3c_drag_to(x0, y0, x1, y1)
|
196
|
+
end
|
197
|
+
|
198
|
+
private
|
199
|
+
|
200
|
+
def is_end_of_scroll?
|
201
|
+
old_elements = @previous_elements
|
202
|
+
@previous_elements = @scrollable.first_and_last_leaf
|
203
|
+
old_elements == @previous_elements
|
204
|
+
end
|
205
|
+
|
206
|
+
def default_deadzone!
|
207
|
+
@deadzone = {} if @deadzone.nil?
|
208
|
+
if @deadzone[:top].nil?
|
209
|
+
@deadzone[:top] = 1
|
210
|
+
else
|
211
|
+
@deadzone[:top] = @deadzone[:top].to_f
|
212
|
+
end
|
213
|
+
if @deadzone[:bottom].nil?
|
214
|
+
@deadzone[:bottom] = 1
|
215
|
+
else
|
216
|
+
@deadzone[:bottom] = @deadzone[:bottom].to_f
|
217
|
+
end
|
218
|
+
if @deadzone[:right].nil?
|
219
|
+
@deadzone[:right] = 1
|
220
|
+
else
|
221
|
+
@deadzone[:right] = @deadzone[:right].to_f
|
222
|
+
end
|
223
|
+
if @deadzone[:left].nil?
|
224
|
+
@deadzone[:left] = 1
|
225
|
+
else
|
226
|
+
@deadzone[:left] = @deadzone[:left].to_f
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
def is_aligned?(with, element)
|
231
|
+
align_bounds = @locator.bounds(force_cache_element: element)
|
232
|
+
case with
|
233
|
+
when :top
|
234
|
+
@align_offset = align_bounds.top_left.y - @bounds.top_left.y + @deadzone[:top]
|
235
|
+
when :bottom
|
236
|
+
@align_offset = @bounds.bottom_right.y - @deadzone[:bottom] - align_bounds.bottom_right.y
|
237
|
+
when :right
|
238
|
+
@align_offset = @bounds.bottom_right.x - @deadzone[:right] - align_bounds.bottom_right.x
|
239
|
+
when :left
|
240
|
+
@align_offset = align_bounds.top_left.x - @bounds.top_left.x + @deadzone[:left]
|
241
|
+
else
|
242
|
+
raise "Unsupported align with option: #{with}"
|
243
|
+
end
|
244
|
+
@align_offset < SCROLL_ALIGNMENT_THRESHOLD
|
245
|
+
end
|
246
|
+
end
|
247
247
|
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
module Selenium
|
2
|
-
module WebDriver
|
3
|
-
class Element
|
4
|
-
# sets the testa appium driver instance for the current phone
|
5
|
-
def self.set_driver(driver, udid)
|
6
|
-
udid = "unknown" if udid.nil?
|
7
|
-
@@drivers ||= {}
|
8
|
-
@@drivers[udid] = driver
|
9
|
-
end
|
10
|
-
|
11
|
-
# @return [TestaAppiumDriver::Driver] testa appium driver instance for the current phone
|
12
|
-
def get_driver
|
13
|
-
udid = @bridge.capabilities.instance_variable_get(:@capabilities)["udid"]
|
14
|
-
udid = "unknown" if udid.nil?
|
15
|
-
@@drivers[udid]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
class Element
|
4
|
+
# sets the testa appium driver instance for the current phone
|
5
|
+
def self.set_driver(driver, udid)
|
6
|
+
udid = "unknown" if udid.nil?
|
7
|
+
@@drivers ||= {}
|
8
|
+
@@drivers[udid] = driver
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [TestaAppiumDriver::Driver] testa appium driver instance for the current phone
|
12
|
+
def get_driver
|
13
|
+
udid = @bridge.capabilities.instance_variable_get(:@capabilities)["udid"]
|
14
|
+
udid = "unknown" if udid.nil?
|
15
|
+
@@drivers[udid]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|