testa_appium_driver 0.1.0 → 0.1.4

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: de964b80dabf1bc1507dcca4f28803c392f7b2da2cc6f8863479550ad55d49f2
4
- data.tar.gz: 1555d6350706198af6a082cc0010295aabf07cebb7bc2527704c69fbbe96efd0
3
+ metadata.gz: ae8c1d10792a04508f11afa6d0b58380d60ba4f079eba2caed9707a5ae036e95
4
+ data.tar.gz: 47b0ca0facbc1cccaddc5a5efd4c2bcadd53f4ac4e8a66f6b4c2f89334cca8ee
5
5
  SHA512:
6
- metadata.gz: f4a5426075f7a95d195e841f6b2043e0ac0401b4df7cefafab1c205f5fc5288c0cd56bdc5ab7cd64a55d1d7aa62b2b97467edc181c2c767ac8f01f0fa18161c0
7
- data.tar.gz: 776de44ceaf20140dc3e414a6ee66b05bb7b74356196f9a644b4f88539c17fe8c68dcfce59bf2115bcda1e3424ee0aa54130f323a2d97c1ada405a2218027f59
6
+ metadata.gz: 62cf8d80a49626ffc88709afde4f408c535e53a25352058a36476c3b9791792b0f5cf17d45e3ac52c228b10909c4e67093c94d5dd6347147e3dce398b7cc18f4
7
+ data.tar.gz: 265b1b055eec368481790df7c50c78b9f803dbd64286d50b60e37fbe1b8bba6a004f9dadf0c07a6fa688f3ce19c0ba190b914aff97296c19214cbfa10b9be0c0
data/.gitignore CHANGED
@@ -10,6 +10,7 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
 
13
+ /.idea/deployment
13
14
  /.idea/workspace.xml
14
15
  /.idea/misc.xml
15
16
  Gemfile.lock
data/.idea/deployment.xml CHANGED
@@ -1,21 +1,14 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <project version="4">
3
- <component name="PublishConfigData" autoUpload="On explicit save action" promptOnRemoteOverwrite="CHECK_CONTENT" serverName="supertesta.com" createEmptyFolders="true" remoteFilesAllowedToDisappearOnAutoupload="false" autoUploadExternalChanges="true">
3
+ <component name="PublishConfigData">
4
4
  <serverData>
5
5
  <paths name="supertesta.com">
6
6
  <serverdata>
7
7
  <mappings>
8
- <mapping deploy="/testa_docker/path_data\testa_appium_driver" local="$PROJECT_DIR$" web="/" />
8
+ <mapping deploy="/testa_docker/path_data/testa_appium_driver" local="$PROJECT_DIR$" web="/" />
9
9
  </mappings>
10
- <excludedPaths>
11
- <excludedPath local="true" path="$PROJECT_DIR$/.idea" />
12
- <excludedPath local="true" path="$PROJECT_DIR$/tmp" />
13
- <excludedPath local="true" path="$PROJECT_DIR$/testa_appium_driver.iml" />
14
- <excludedPath local="true" path="$PROJECT_DIR$/Gemfile.lock" />
15
- </excludedPaths>
16
10
  </serverdata>
17
11
  </paths>
18
12
  </serverData>
19
- <option name="myAutoUpload" value="ON_EXPLICIT_SAVE" />
20
13
  </component>
21
14
  </project>
data/.idea/webServers.xml CHANGED
@@ -2,7 +2,7 @@
2
2
  <project version="4">
3
3
  <component name="WebServers">
4
4
  <option name="servers">
5
- <webServer id="b1f6f214-0ed7-4869-998b-43dc6e5c154a" name="supertesta.com">
5
+ <webServer id="b1f6f214-0ed7-4869-998b-43dc6e5c154a" name="supertesta.com" url="http://something">
6
6
  <fileTransfer rootFolder="/ruby_apps" accessType="SFTP" host="supertesta.com" port="22" sshConfigId="ea45cb27-d516-4292-a1f7-430f02857685" sshConfig="Supertesta.com">
7
7
  <advancedOptions>
8
8
  <advancedOptions dataProtectionLevel="Private" keepAliveTimeout="0" passiveMode="true" shareSSLContext="true" />
data/README.md CHANGED
@@ -1,52 +1,365 @@
1
- # TestaAppiumDriver
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library
4
- into a gem. Put your Ruby code in the file `lib/testa_appium_driver`. To experiment with that code, run `bin/console`
5
- for an interactive prompt.
6
-
7
- TODO: Delete this and the text above, and describe your gem
8
-
9
- ## Installation
10
-
11
- Add this line to your application's Gemfile:
12
-
13
- ```ruby
14
- gem 'testa_appium_driver'
15
- ```
16
-
17
- And then execute:
18
-
19
- $ bundle install
20
-
21
- Or install it yourself as:
22
-
23
- $ gem install testa_appium_driver
24
-
25
- ## Usage
26
-
27
- TODO: Write usage instructions here
28
-
29
- ## Development
30
-
31
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can
32
- also run `bin/console` for an interactive prompt that will allow you to experiment.
33
-
34
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
35
- version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
36
- push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
37
-
38
- ## Contributing
39
-
40
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/testa_appium_driver. This project
41
- is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
42
- the [code of conduct](https://github.com/[USERNAME]/testa_appium_driver/blob/master/CODE_OF_CONDUCT.md).
43
-
44
- ## License
45
-
46
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
47
-
48
- ## Code of Conduct
49
-
50
- Everyone interacting in the TestaAppiumDriver project's codebases, issue trackers, chat rooms and mailing lists is
51
- expected to follow
52
- the [code of conduct](https://github.com/[USERNAME]/testa_appium_driver/blob/master/CODE_OF_CONDUCT.md).
1
+ # Testa Appium Driver
2
+
3
+ Testa appium driver is a wrapper around the `ruby_lib_core` driver for appium.
4
+ It leverages all driver features and makes them simple and easy to use.
5
+
6
+ There are two key concepts in the testa driver
7
+ #### 1. Elements are fetched only when needed
8
+ It allows you to chain all the selectors and use the adjacent selectors without finding each element in the chain.
9
+ For example `driver.linear_layout.list_view.view_group.button` will not execute any find element commands
10
+ because element command is not given. If `click`, `send_keys` or any attribute method is added to the end of chain
11
+ it will execute find_element before triggering the given element command.
12
+
13
+ This concept allows you to store the selectors and reuse them later on. For example
14
+ ```ruby
15
+ # element is not fetched yet
16
+ my_fancy_progress_bar = driver.linear_layout.progress_bar
17
+
18
+ puts my_fancy_progress_bar.text # will fetch the element and print the text (output: "You are on the first page")
19
+ driver.button(text: "next page").click # go to the next page that has the same progress bar locator
20
+
21
+ # will fetch the element again and print the text (output: "You are on the second page")
22
+ # without TestaAppiumDriver, a Stale Object Exception would be thronw
23
+ puts my_fancy_progress_bar.text
24
+ ```
25
+
26
+
27
+ #### 2. The Best element find / scroll strategy is automatically determined
28
+ When given an element locator such as the progress_bar in the first concept, testa appium driver automatically determines
29
+ the best find element strategy. The only thing to keep in mind is that you cannot mix strategy specific selectors.
30
+ Strategy specific selectors are `from_parent` for uiautomator or `parent`, `siblings` or `children` for xpath strategy.
31
+
32
+ There are also multiple scroll strategies. Android supports both `uiautomator` and `w3c`, while iOS only supports `w3c`
33
+ scroll strategy. Uiautomator scroll strategy is more fluent and faster but it cannot be limited with single direction
34
+ element finding, and it does not have sufficient deadzone support.
35
+
36
+
37
+
38
+
39
+ ## Installation
40
+
41
+ Add this line to your application's Gemfile:
42
+
43
+ ```ruby
44
+ gem 'testa_appium_driver'
45
+ ```
46
+
47
+ And then execute:
48
+
49
+ $ bundle install
50
+
51
+ Or install it yourself as:
52
+
53
+ $ gem install testa_appium_driver
54
+
55
+
56
+ For the android platform, make sure you are using the latest version of uiautomator server. Versions older than 4.21.2 have breaking issues.
57
+ To get the latest server version execute:
58
+ ```shell script
59
+ npm install appium-uiautomator2-server
60
+ ```
61
+ And apks will be located in `./node_modules/appium-uiautomator2-server/apks`. Install both apks on the target device
62
+ and make sure you have the `skipServerInstallation: true` capability when starting the driver.
63
+ ## Usage
64
+
65
+ ### Initialization
66
+ ```ruby
67
+ opts = {
68
+ caps: {
69
+ platformName: "Android",
70
+ deviceName: "MyPhone",
71
+ app: "/path/to/your/apk",
72
+ udid: "your_phone_udid",
73
+ automationName: "uiautomator2",
74
+ skipServerInstallation: true, # if uiautomator server is manually installed
75
+ enableMultiWindows: true, # enables appium to see some otherwise "hidden" elements
76
+ }
77
+ }
78
+ driver = TestaAppiumDriver::Driver.new(opts)
79
+ ```
80
+
81
+ #### Example 1
82
+ ```ruby
83
+ driver.linear_layout.button(id: "com.package.name:id/myElementId").click
84
+ ```
85
+ Looks for the first linear layout and a button within the linear layout that has the provided id.
86
+ Only 1 find element is executed with the resolved strategy (xpath or uiautomator):<br>
87
+ underlying selectors:<br>
88
+ xpath: `//android.widget.LinearLayout[1]//android.widget.Button[@resource-id="com.package.name:id/myElementId"]` <br>
89
+ uiautomator: `new UiSelector().className("android.widget.LinearLayout").instance(0).childSelector(new UiSelector.className("android.widget.Button").resourceId("com.package.name:id/myElementId")));`<br>
90
+
91
+ #### Example 2
92
+ ```ruby
93
+ driver.linear_layout(id: "myShortIdExample").parent.text_view.wait_until_exists(10).text
94
+ ```
95
+ Testa driver converts shorthand ids(that dont have :id/) to full ids
96
+ by reading the current package under test and prepending it to the shorthand id. If you don't want to prepend the package
97
+ name to the id, use = sign before the id, for example `id: "=idWithoutAPackageName"`.
98
+
99
+ After adding the `parent` and `text_view` selectors and before retrieving the text value `wait_until_exists(10)` is used to
100
+ wait up to 10 seconds for the element to appear in the page before exception is thrown.
101
+
102
+ underlying selectors:<br>
103
+ xpath: `//android.widget.LinearLayout[@resource-id="com.package.name:id/myShortIdExample"][1]/../android.widget.TextView[1]` <br>
104
+ uiautomator: `exception: parent selector cannot be used with uiautomator strategy`
105
+
106
+ #### Example 3
107
+ ```ruby
108
+ driver.list_view(top: 200).edit_text(text: "Looking for this text").scroll_to.align!(:bottom).enabled?
109
+ ```
110
+ If the element cannot be found in the current view, `scroll_to` action will scroll to start of the scrollable container,
111
+ and start scrolling to the end until the element is found or end is reached. Once found the `align!(:bottom)` command
112
+ will align the element to the bottom of the scrollable container.
113
+ Finally, once the element is scrolled into view and aligned, it will check if the edit_text is enabled.
114
+
115
+ The scrollable container is resolved by looking the chain of selectors.
116
+ Selector can be a scrollable container if `scrollable: true` or is one of the scrollable classes:
117
+ - android.widget.ListView
118
+ - android.widget.ScrollView
119
+ - android.widget.HorizontalScrollView
120
+ - androidx.recyclerview.widget.RecyclerView
121
+ - XCUIElementTypeScrollView
122
+
123
+ If the selector chain does not contain a scrollable container, a `driver.scrollabe` command will be executed to
124
+ retrieve the first scrollable element in page.
125
+
126
+ Scrollable selectors can accept the `top`, `right`, `bottom` and `left` parameters as deadzone to prevent that edge of the
127
+ container be used as scrollable surface.
128
+ Custom views can also be used as scrollable containers with `as_scrollable` command.
129
+ The command marks the last selector as scrollable container.
130
+ `driver.view(id: "myCustomScrollableView").as_scrollable(top: 200).page_down`
131
+
132
+
133
+
134
+
135
+
136
+ #### Example 4
137
+ ```ruby
138
+ driver.buttons.each do |element|
139
+ puts element.text
140
+ end
141
+ ```
142
+ The `each` method is one of the scrollable actions. It will start from the beginning of the scrollable container,
143
+ in this case `driver.scrollable`, and find every button in the screen. It will scroll the page until the end of scrollable
144
+ container is reached and all buttons are found.
145
+
146
+
147
+
148
+ #### Example 5 (Invalid combination)
149
+ ```ruby
150
+ driver.frame_layout.from_parent.button(text: "My Cool text").siblings
151
+ ```
152
+ This example demonstrates a invalid selector because it cannot be resolved with xpath nor uiautomator strategy.
153
+ It will raise StrategyMixException because from_parent selector can only be used with uiautomator strategy and
154
+ siblings selector can only be used with xpath strategy.
155
+
156
+
157
+ # Methods
158
+
159
+ ## Android
160
+ ### Class Selectors
161
+ - element
162
+ - elements
163
+ - scrollable
164
+ - scrollables
165
+ - image_view
166
+ - image_views
167
+ - frame_layout
168
+ - frame_layouts
169
+ - linear_layout
170
+ - linear_layouts
171
+ - view
172
+ - views
173
+ - edit_text
174
+ - edit_texts
175
+ - view_group
176
+ - view_groups
177
+ - relative_layout
178
+ - relative_layouts
179
+ - recycler_view
180
+ - recycler_views
181
+ - button
182
+ - buttons
183
+ - image_button
184
+ - image_buttons
185
+ - horizontal_scroll_view
186
+ - horizontal_scroll_views
187
+ - scroll_view
188
+ - scroll_views
189
+ - view_pager
190
+ - view_pagers
191
+ - check_box
192
+ - check_boxes
193
+ - list_view
194
+ - list_views
195
+ - progress_bar
196
+ - progress_bars
197
+ - radio_button
198
+ - radio_buttons
199
+ - radio_group
200
+ - radio_groups
201
+ - search_view
202
+ - search_views
203
+ - spinner
204
+ - spinners
205
+ - toast
206
+ - toasts
207
+ - toolbar
208
+ - toolbars
209
+ - text_view
210
+ - text_views
211
+
212
+ Adjacent selectors
213
+ - from_parent
214
+ - parent
215
+ - child
216
+ - children
217
+ - siblings
218
+ - preceding_sibling
219
+ - preceding_siblings
220
+ - following_sibling
221
+ - following_siblings
222
+
223
+
224
+ Class Selector arguments
225
+ - id
226
+ - long_clickable
227
+ - desc
228
+ - class
229
+ - text
230
+ - package
231
+ - checkable
232
+ - checked
233
+ - clickable
234
+ - enabled
235
+ - focusable
236
+ - focused
237
+ - index
238
+ - selected
239
+ - scrollable
240
+
241
+ ### Attributes
242
+ - text
243
+ - package
244
+ - class_name
245
+ - checkable?
246
+ - checked?
247
+ - clickable?
248
+ - desc
249
+ - enabled?
250
+ - focusable?
251
+ - focused?
252
+ - long_clickable?
253
+ - password?
254
+ - id
255
+ - scrollable?
256
+ - selected?
257
+ - displayed?
258
+ - selection_start
259
+ - selection_end
260
+ - bounds
261
+ - index
262
+
263
+ # iOS
264
+ ## Type Selectors
265
+ - element
266
+ - elements
267
+ - window
268
+ - windows
269
+ - other
270
+ - others
271
+ - navigation_bar
272
+ - navigation_bars
273
+ - button
274
+ - buttons
275
+ - image
276
+ - images
277
+ - static_text
278
+ - static_texts
279
+ - scrollable
280
+ - scrollables
281
+ - scroll_view
282
+ - scroll_views
283
+ - table
284
+ - tables
285
+ - cell
286
+ - cells
287
+
288
+ Adjacent selectors
289
+ - parent
290
+ - child
291
+ - children
292
+ - siblings
293
+ - preceding_sibling
294
+ - preceding_siblings
295
+ - following_sibling
296
+ - following_siblings
297
+
298
+ Type Selector arguments
299
+ - enabled
300
+ - type, class
301
+ - label
302
+ - width
303
+ - height
304
+ - visible
305
+ - name, id
306
+ - value
307
+
308
+
309
+ ## Attributes
310
+ - accessibility_container
311
+ - accessible?
312
+ - class_name
313
+ - enabled?
314
+ - frame
315
+ - index
316
+ - label, text
317
+ - name
318
+ - rect, bounds
319
+ - selected?
320
+ - type
321
+ - value
322
+ - visible?
323
+
324
+ # Scroll actions
325
+ - each
326
+ - align!
327
+ - align_top!
328
+ - align_bottom!
329
+ - align_left!
330
+ - align_right!
331
+ - align
332
+ - align_top
333
+ - align_bottom
334
+ - align_left
335
+ - align_right
336
+ - scroll_to
337
+ - scroll_down_to
338
+ - scroll_up_to
339
+ - scroll_right_to
340
+ - scroll_left_to
341
+ - scroll_to_start
342
+ - scroll_to_end
343
+ - page_down
344
+ - page_up
345
+ - page_left
346
+ - page_right
347
+ - fling_down
348
+ - fling_up
349
+ - fling_left
350
+ - fling_right
351
+ - drag_to
352
+ - drag_by
353
+
354
+ # Helpers
355
+ - as_scrollable
356
+ - wait_until_exists
357
+ - wait_while_exists
358
+ - exists?
359
+ - long_tap
360
+
361
+ ## License
362
+
363
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
364
+
365
+