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,438 +0,0 @@
1
- module ::TestaAppiumDriver
2
- #noinspection ALL
3
- module ClassSelectors
4
-
5
- # @return [TestaAppiumDriver::Locator]
6
- def add_selector(*args, &block)
7
- # if class selector is executed from driver, create new locator instance
8
- if self.kind_of?(TestaAppiumDriver::Driver) || self.instance_of?(::Selenium::WebDriver::Element) || self.instance_of?(::Appium::Core::Element)
9
- args.last[:default_find_strategy] = @default_find_strategy
10
- args.last[:default_scroll_strategy] = @default_scroll_strategy
11
- if self.instance_of?(::Selenium::WebDriver::Element) || self.instance_of?(::Appium::Core::Element)
12
- driver = self.get_driver
13
- else
14
- driver = self
15
- end
16
- Locator.new(driver, self, *args)
17
- else
18
- # class selector is executed from locator, just add child selector criteria
19
- self.add_child_selector(*args)
20
- end
21
- end
22
-
23
- # first element that match given selectors
24
- # @param selectors [Hash]
25
- # @return [TestaAppiumDriver::Locator] first element
26
- def element(selectors = {})
27
- unless selectors[:image].nil?
28
- selectors[:strategy] = FIND_STRATEGY_IMAGE
29
- end
30
- add_selector(selectors)
31
- end
32
-
33
- # all elements that match given selectors
34
- # @param params [Hash]
35
- # @return [TestaAppiumDriver::Locator] all elements that match given selectors
36
- def elements(params = {})
37
- unless params[:image].nil?
38
- params[:strategy] = FIND_STRATEGY_IMAGE
39
- end
40
- params[:single] = false
41
- add_selector(params)
42
- end
43
-
44
-
45
- # first android.widget.ImageView element that match given selectors
46
- # @return [TestaAppiumDriver::Locator]
47
- def image_view(params = {})
48
- params[:class] = "android.widget.ImageView"
49
- add_selector(params)
50
- end
51
-
52
- # all android.widget.ImageView elements that match given selectors
53
- # @return [TestaAppiumDriver::Locator]
54
- def image_views(params = {})
55
- params[:class] = "android.widget.ImageView"
56
- params[:single] = false
57
- add_selector(params)
58
- end
59
-
60
- # first android.widget.FrameLayout element that match given selectors
61
- # @return [TestaAppiumDriver::Locator]
62
- def frame_layout(params = {})
63
- params[:class] = "android.widget.FrameLayout"
64
- add_selector(params)
65
- end
66
-
67
- # all android.widget.FrameLayout elements that match given selectors
68
- # @return [TestaAppiumDriver::Locator]
69
- def frame_layouts(params = {})
70
- params[:class] = "android.widget.FrameLayout"
71
- params[:single] = false
72
- add_selector(params)
73
- end
74
-
75
- # first android.widget.LinearLayout element that match given selectors
76
- # @return [TestaAppiumDriver::Locator]
77
- def linear_layout(params = {})
78
- params[:class] = "android.widget.LinearLayout"
79
- add_selector(params)
80
- end
81
-
82
- # all android.widget.LinearLayout elements that match given selectors
83
- # @return [TestaAppiumDriver::Locator]
84
- def linear_layouts(params = {})
85
- params[:class] = "android.widget.LinearLayout"
86
- params[:single] = false
87
- add_selector(params)
88
- end
89
-
90
- # first android.view.View element that match given selectors
91
- # @return [TestaAppiumDriver::Locator]
92
- def view(params = {})
93
- params[:class] = "android.view.View"
94
- add_selector(params)
95
- end
96
-
97
- # all android.view.View elements that match given selectors
98
- # @return [TestaAppiumDriver::Locator]
99
- def views(params = {})
100
- params[:class] = "android.view.View"
101
- params[:single] = false
102
- add_selector(params)
103
- end
104
-
105
- # first android.widget.EditText element that match given selectors
106
- # @return [TestaAppiumDriver::Locator]
107
- def edit_text(params = {})
108
- params[:class] = "android.widget.EditText"
109
- add_selector(params)
110
- end
111
-
112
- # all android.widget.EditText elements that match given selectors
113
- # @return [TestaAppiumDriver::Locator]
114
- def edit_texts(params = {})
115
- params[:class] = "android.widget.EditText"
116
- params[:single] = false
117
- add_selector(params)
118
- end
119
-
120
- # first android.view.ViewGroup element that match given selectors
121
- # @return [TestaAppiumDriver::Locator]
122
- def view_group(params = {})
123
- params[:class] = "android.view.ViewGroup"
124
- add_selector(params)
125
- end
126
-
127
- # all android.view.ViewGroup elements that match given selectors
128
- # @return [TestaAppiumDriver::Locator]
129
- def view_groups(params = {})
130
- params[:class] = "android.view.ViewGroup"
131
- params[:single] = false
132
- add_selector(params)
133
- end
134
-
135
- # first android.widget.RelativeLayout element that match given selecotrs
136
- # @return [TestaAppiumDriver::Locator]
137
- def relative_layout(params = {})
138
- params[:class] = "android.widget.RelativeLayout"
139
- add_selector(params)
140
- end
141
-
142
- # all android.widget.RelativeLayout elements that match given selectors
143
- # @return [TestaAppiumDriver::Locator]
144
- def relative_layouts(params = {})
145
- params[:class] = "android.widget.RelativeLayout"
146
- params[:single] = false
147
- add_selector(params)
148
- end
149
-
150
- # first androidx.recyclerview.widget.RecyclerView element that match given selectors
151
- # @return [TestaAppiumDriver::Locator]
152
- def recycler_view(params = {})
153
- params[:class] = "androidx.recyclerview.widget.RecyclerView"
154
- add_selector(params)
155
- end
156
-
157
- # all androidx.recyclerview.widget.RecyclerView elements that match given selectors
158
- # @return [TestaAppiumDriver::Locator]
159
- def recycler_views(params = {})
160
- params[:class] = "androidx.recyclerview.widget.RecyclerView"
161
- params[:single] = false
162
- add_selector(params)
163
- end
164
-
165
- # first android.widget.Button element that match given selectors
166
- # @return [TestaAppiumDriver::Locator]
167
- def button(params = {})
168
- params[:class] = "android.widget.Button"
169
- add_selector(params)
170
- end
171
-
172
- # all android.widget.Button elements that match given selectors
173
- # @return [TestaAppiumDriver::Locator]
174
- def buttons(params = {})
175
- params[:class] = "android.widget.Button"
176
- params[:single] = false
177
- add_selector(params)
178
- end
179
-
180
- # first android.widget.ImageButton element that match given selectors
181
- # @return [TestaAppiumDriver::Locator]
182
- def image_button(params = {})
183
- params[:class] = "android.widget.ImageButton"
184
- add_selector(params)
185
- end
186
-
187
- # all android.widget.ImageButton elements that match given selectors
188
- # @return [TestaAppiumDriver::Locator]
189
- def image_buttons(params = {})
190
- params[:class] = "android.widget.ImageButton"
191
- params[:single] = false
192
- add_selector(params)
193
- end
194
-
195
- # first android.widget.HorizontalScrollView element that match given selectors
196
- # @return [TestaAppiumDriver::Locator]
197
- def horizontal_scroll_view(params = {})
198
- params[:class] = "android.widget.HorizontalScrollView"
199
- add_selector(params)
200
- end
201
-
202
- # all android.widget.HorizontalScrollView elements that match given selectors
203
- # @return [TestaAppiumDriver::Locator]
204
- def horizontal_scroll_views(params = {})
205
- params[:class] = "android.widget.HorizontalScrollView"
206
- params[:single] = false
207
- add_selector(params)
208
- end
209
-
210
- # first android.widget.ScrollView element that match given selectors
211
- # @return [TestaAppiumDriver::Locator]
212
- def scroll_view(params = {})
213
- params[:class] = "android.widget.ScrollView"
214
- add_selector(params)
215
- end
216
-
217
- # all android.widget.ScrollView elements that match given selectors
218
- # @return [TestaAppiumDriver::Locator]
219
- def scroll_views(params = {})
220
- params[:class] = "android.widget.ScrollView"
221
- params[:single] = false
222
- add_selector(params)
223
- end
224
-
225
- # first viewpager.widget.ViewPager element that match given selectors
226
- # @return [TestaAppiumDriver::Locator]
227
- def view_pager(params = {})
228
- params[:class] = "androidx.viewpager.widget.ViewPager"
229
- add_selector(params)
230
- end
231
-
232
- # all viewpager.widget.ViewPager elements that match given selectors
233
- # @return [TestaAppiumDriver::Locator]
234
- def view_pagers(params = {})
235
- params[:class] = "androidx.viewpager.widget.ViewPager"
236
- params[:single] = false
237
- add_selector(params)
238
- end
239
-
240
- # first android.widget.CheckBox element that match given selectors
241
- # @return [TestaAppiumDriver::Locator]
242
- def check_box(params = {})
243
- params[:class] = "android.widget.CheckBox"
244
- add_selector(params)
245
- end
246
-
247
- # all android.widget.CheckBox elements that match given selectors
248
- # @return [TestaAppiumDriver::Locator]
249
- def check_boxes(params = {})
250
- params[:class] = "android.widget.CheckBox"
251
- params[:single] = false
252
- add_selector(params)
253
- end
254
-
255
- # first android.widget.ListView element that match given selectors
256
- # @return [TestaAppiumDriver::Locator]
257
- def list_view(params = {})
258
- params[:class] = "android.widget.ListView"
259
- add_selector(params)
260
- end
261
-
262
- # all android.widget.ListView elements that match given selectors
263
- # @return [TestaAppiumDriver::Locator]
264
- def list_views(params = {})
265
- params[:class] = "android.widget.ListView"
266
- params[:single] = false
267
- add_selector(params)
268
- end
269
-
270
- # first android.widget.ProgressBar element that match given selectors
271
- # @return [TestaAppiumDriver::Locator]
272
- def progress_bar(params = {})
273
- params[:class] = "android.widget.ProgressBar"
274
- add_selector(params)
275
- end
276
-
277
- # all android.widget.ProgressBar elements that match given selectors
278
- # @return [TestaAppiumDriver::Locator]
279
- def progress_bars(params = {})
280
- params[:class] = "android.widget.ProgressBar"
281
- params[:single] = false
282
- add_selector(params)
283
- end
284
-
285
- # first android.widget.RadioButton element that match given selectors
286
- # @return [TestaAppiumDriver::Locator]
287
- def radio_button(params = {})
288
- params[:class] = "android.widget.RadioButton"
289
- add_selector(params)
290
- end
291
-
292
- # all android.widget.RadioButton elements that match given selectors
293
- # @return [TestaAppiumDriver::Locator]
294
- def radio_buttons(params = {})
295
- params[:class] = "android.widget.RadioButton"
296
- params[:single] = false
297
- add_selector(params)
298
- end
299
-
300
- # first android.widget.RadioGroup element that match given selectors
301
- # @return [TestaAppiumDriver::Locator]
302
- def radio_group(params = {})
303
- params[:class] = "android.widget.RadioGroup"
304
- add_selector(params)
305
- end
306
-
307
- # all android.widget.RadioGroup elements that match given selectors
308
- # @return [TestaAppiumDriver::Locator]
309
- def radio_groups(params = {})
310
- params[:class] = "android.widget.RadioGroup"
311
- params[:single] = false
312
- add_selector(params)
313
- end
314
-
315
- # first android.widget.SearchView element that match given selectors
316
- # @return [TestaAppiumDriver::Locator]
317
- def search_view(params = {})
318
- params[:class] = "android.widget.SearchView"
319
- add_selector(params)
320
- end
321
-
322
- # all android.widget.SearchView elements that match given selectors
323
- # @return [TestaAppiumDriver::Locator]
324
- def search_views(params = {})
325
- params[:class] = "android.widget.SearchView"
326
- params[:single] = false
327
- add_selector(params)
328
- end
329
-
330
- # first android.widget.Spinner element that match given selectors
331
- # @return [TestaAppiumDriver::Locator]
332
- def spinner(params = {})
333
- params[:class] = "android.widget.Spinner"
334
- add_selector(params)
335
- end
336
-
337
- # all android.widget.Spinner elements that match given selectors
338
- # @return [TestaAppiumDriver::Locator]
339
- def spinners(params = {})
340
- params[:class] = "android.widget.Spinner"
341
- params[:single] = false
342
- add_selector(params)
343
- end
344
-
345
- # first android.widget.Toast element that match given selectors
346
- # @return [TestaAppiumDriver::Locator]
347
- def toast(params = {})
348
- params[:class] = "android.widget.Toast"
349
- add_selector(params)
350
- end
351
-
352
- # all android.widget.Toast elements that match given selectors
353
- # @return [TestaAppiumDriver::Locator]
354
- def toasts(params = {})
355
- params[:class] = "android.widget.Toast"
356
- params[:single] = false
357
- add_selector(params)
358
- end
359
-
360
- # first android.widget.Toolbar element that match given selectors
361
- # @return [TestaAppiumDriver::Locator]
362
- def toolbar(params = {})
363
- params[:class] = "android.widget.Toolbar"
364
- add_selector(params)
365
- end
366
-
367
- # all android.widget.Toolbar elements that match given selectors
368
- # @return [TestaAppiumDriver::Locator]
369
- def toolbars(params = {})
370
- params[:class] = "android.widget.Toolbar"
371
- params[:single] = false
372
- add_selector(params)
373
- end
374
-
375
- # first android.widget.TextView element that match given selectors
376
- # @return [TestaAppiumDriver::Locator]
377
- def text_view(params = {})
378
- params[:class] = "android.widget.TextView"
379
- add_selector(params)
380
- end
381
-
382
- # all android.widget.TextView elements that match given selectors
383
- # @return [TestaAppiumDriver::Locator]
384
- def text_views(params = {})
385
- params[:class] = "android.widget.TextView"
386
- params[:single] = false
387
- add_selector(params)
388
- end
389
-
390
-
391
- # first androidx.cardview.widget.CardView element that match given selectors
392
- # @return [TestaAppiumDriver::Locator]
393
- def card_view(params = {})
394
- params[:class] = "androidx.cardview.widget.CardView"
395
- add_selector(params)
396
- end
397
-
398
- # all androidx.cardview.widget.CardView elements that match given selectors
399
- # @return [TestaAppiumDriver::Locator]
400
- def card_views(params = {})
401
- params[:class] = "androidx.cardview.widget.CardView"
402
- params[:single] = false
403
- add_selector(params)
404
- end
405
-
406
- # first android.widget.Switch element that match given selectors
407
- # @return [TestaAppiumDriver::Locator]
408
- def switch(params = {})
409
- params[:class] = "android.widget.Switch"
410
- add_selector(params)
411
- end
412
-
413
- # all android.widget.Switch elements that match given selectors
414
- # @return [TestaAppiumDriver::Locator]
415
- def switches(params = {})
416
- params[:class] = "android.widget.Switch"
417
- params[:single] = false
418
- add_selector(params)
419
- end
420
-
421
-
422
- # first android.webkit.WebView element that match given selectors
423
- # @return [TestaAppiumDriver::Locator]
424
- def web_view(params = {})
425
- params[:class] = "android.webkit.WebView"
426
- add_selector(params)
427
- end
428
-
429
- # all android.webkit.WebView elements that match given selectors
430
- # @return [TestaAppiumDriver::Locator]
431
- def web_views(params = {})
432
- params[:class] = "android.webkit.WebView"
433
- params[:single] = false
434
- add_selector(params)
435
- end
436
-
437
- end
438
- end
@@ -1,71 +0,0 @@
1
- require_relative 'class_selectors'
2
- require_relative 'locator'
3
- require_relative 'scroll_actions/uiautomator_scroll_actions'
4
- require_relative 'selenium_element'
5
-
6
- module TestaAppiumDriver
7
- class Driver
8
- include ClassSelectors
9
-
10
-
11
-
12
- # executes shell command
13
- # @param [String] command Shell command name to execute for example echo or rm
14
- # @param [Array<String>] args Array of command arguments, example: ['-f', '/sdcard/my_file.txt']
15
- # @param [Integer] timeout Command timeout in milliseconds. If the command blocks for longer than this timeout then an exception is going to be thrown. The default timeout is 20000 ms
16
- # @param [Boolean] includeStderr Whether to include stderr stream into the returned result.
17
- def shell(command, args: nil, timeout: nil, includeStderr: true)
18
- params = {
19
- command: command,
20
- includeStderr: includeStderr
21
- }
22
- params[:args] = args unless args.nil?
23
- params[:timeout] = timeout unless timeout.nil?
24
- @driver.execute_script("mobile: shell", params)
25
- end
26
-
27
-
28
- def scrollable
29
- locator = Locator.new(self, self, {single: true})
30
- locator.xpath_selector = "//androidx.recyclerview.widget.RecyclerView|//android.widget.ScrollView|//android.widget.ListView|//android.widget.HorizontalScrollView"
31
- locator.ui_selector = "new UiSelector().scrollable(true).instance(0)"
32
- locator
33
- end
34
-
35
-
36
- def scrollables
37
- locator = Locator.new(self, self, {single: false})
38
- locator.xpath_selector = "//androidx.recyclerview.widget.RecyclerView|//android.widget.ScrollView|//android.widget.ListView|//android.widget.HorizontalScrollView"
39
- locator.ui_selector = "new UiSelector().scrollable(true)"
40
- locator
41
- end
42
-
43
-
44
-
45
- private
46
- def handle_testa_opts
47
- if @testa_opts[:default_find_strategy].nil?
48
- @default_find_strategy = DEFAULT_ANDROID_FIND_STRATEGY
49
- else
50
- case @testa_opts[:default_find_strategy].to_sym
51
- when FIND_STRATEGY_UIAUTOMATOR, FIND_STRATEGY_XPATH
52
- @default_find_strategy = @testa_opts[:default_find_strategy].to_sym
53
- else
54
- raise "Default find strategy #{@testa_opts[:default_find_strategy]} not supported for Android"
55
- end
56
- end
57
-
58
-
59
- if @testa_opts[:default_scroll_strategy].nil?
60
- @default_scroll_strategy = DEFAULT_ANDROID_SCROLL_STRATEGY
61
- else
62
- case @testa_opts[:default_scroll_strategy].to_sym
63
- when SCROLL_STRATEGY_W3C, SCROLL_STRATEGY_UIAUTOMATOR
64
- @default_scroll_strategy = @testa_opts[:default_scroll_strategy].to_sym
65
- else
66
- raise "Default scroll strategy #{@testa_opts[:default_scroll_strategy]} not supported for Android"
67
- end
68
- end
69
- end
70
- end
71
- end
@@ -1,118 +0,0 @@
1
- module TestaAppiumDriver
2
- module Attributes
3
-
4
- #noinspection RubyNilAnalysis
5
- def testa_attribute(name, *args)
6
- if self.instance_of?(::Selenium::WebDriver::Element) || self.instance_of?(::Appium::Core::Element)
7
- @driver = get_driver # does not get correct driver
8
- elements = self
9
- else
10
- elements = execute(*args)
11
- raise "Element not found" if elements.nil?
12
- end
13
-
14
-
15
-
16
- if elements.kind_of?(::Selenium::WebDriver::Element) || elements.kind_of?(::Appium::Core::Element)
17
- r = elements.send(:attribute, name.to_s)
18
- r = TestaAppiumDriver::Bounds.from_android(r, @driver) if name.to_s == "bounds"
19
- else
20
- r = elements.map { |e| e.send(:attribute, name.to_s) }
21
- r.map! { |b| TestaAppiumDriver::Bounds.from_android(b, @driver) } if name.to_s == "bounds"
22
- end
23
- r
24
- end
25
-
26
- def text(*args)
27
- testa_attribute("text", *args)
28
- end
29
-
30
- def package(*args)
31
- testa_attribute("package", *args)
32
- end
33
-
34
- def class_name(*args)
35
- testa_attribute("className", *args)
36
- end
37
-
38
- def checkable?(*args)
39
- testa_attribute("checkable", *args).to_s == "true"
40
- end
41
-
42
- def checked?(*args)
43
- testa_attribute("checked", *args).to_s == "true"
44
- end
45
-
46
- def clickable?(*args)
47
- testa_attribute("clickable", *args).to_s == "true"
48
- end
49
-
50
- def desc(*args)
51
- testa_attribute("contentDescription", *args)
52
- end
53
-
54
- def enabled?(*args)
55
- testa_attribute("enabled", *args).to_s == "true"
56
- end
57
-
58
- def focusable?(*args)
59
- testa_attribute("focusable", *args).to_s == "true"
60
- end
61
-
62
- def focused?(*args)
63
- testa_attribute("focused", *args).to_s == "true"
64
- end
65
-
66
- def long_clickable?(*args)
67
- testa_attribute("longClickable", *args).to_s == "true"
68
- end
69
-
70
- def password?(*args)
71
- testa_attribute("password", *args).to_s == "true"
72
- end
73
-
74
- def id(*args)
75
- testa_attribute("resourceId", *args)
76
- end
77
-
78
- def scrollable?(*args)
79
- testa_attribute("scrollable", *args).to_s == "true"
80
- end
81
-
82
- def selected?(*args)
83
- testa_attribute("selected", *args).to_s == "true"
84
- end
85
-
86
- def displayed?(*args)
87
- testa_attribute("displayed", *args).to_s == "true"
88
- end
89
-
90
- def selection_start(*args)
91
- testa_attribute("selection-start", *args)
92
- end
93
-
94
- def selection_end(*args)
95
- testa_attribute("selection-end", *args)
96
- end
97
-
98
- def bounds(*args)
99
- testa_attribute("bounds", *args)
100
- end
101
-
102
- end
103
-
104
- class Locator
105
-
106
- # element index in parent element, starts from 0
107
- #noinspection RubyNilAnalysis,RubyYardReturnMatch
108
- # @return [Integer, nil] index of element
109
- def index(*args)
110
- raise "Index not supported for uiautomator strategy" if @strategy == FIND_STRATEGY_UIAUTOMATOR
111
- this = execute(*args)
112
- children = self.dup.parent.children.execute
113
- index = children.index(this)
114
- raise "Index not found" if index.nil?
115
- index.to_i
116
- end
117
- end
118
- end