percy-appium-app 0.0.2 → 0.0.3

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +191 -1
  3. data/percy/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 977a7a790f27d4907f95f7fe43de80d9b22e755320f159a491615a642a836a1d
4
- data.tar.gz: e9eb127a4f084f12bffc64aa4263928bf0931352a5ff60d408f91f9e955b0204
3
+ metadata.gz: 3a9d215b1a1e9daf04d5672a65a909db34bf2f9118e7551a72a83ba742e3dcbf
4
+ data.tar.gz: d5bd4454dbb19e0f649025ebb21692a847b1e6f14a4bf85f67c16749ff462349
5
5
  SHA512:
6
- metadata.gz: e50bd2ad6f3fda122ef560e6e264bb2eb1bde38d48d6fcef7a3a53193d1af021d19bd60e04c8785e29cbeb0b5db4372b86ef43779d4716fb6c1006e60c5ab1ed
7
- data.tar.gz: 1ce875348fe37874f4fa9d2089a7a9159aedd0977b7f9e5aa1c3042218b0778b098becdcc0fcd5aeb3767c3f0284276dbe170221d7b2beef797fe39a9ed32863
6
+ metadata.gz: 10f4a8d07bdc08deb1068025032f05cedacd3959244a1fbd5465ce9ed2eac0a502ab629abeb3087849ad62d9edf874dc298b49a8e14c9c2e36b2b4da71d9f1f6
7
+ data.tar.gz: ef3897862dacf57e5b64b8026a0272415b7ea47a09cdd80e83bc8bcc51d7be02dc4243b4b3e99f268a841934b0131112d37610abef8c5801b21e0e208eb17c8d
data/README.md CHANGED
@@ -1 +1,191 @@
1
- # percy-appium-ruby
1
+ # percy-appium-ruby
2
+
3
+ [Percy](https://percy.io) visual testing for Ruby Appium.
4
+
5
+ ## Installation
6
+
7
+ npm install `@percy/cli`:
8
+
9
+ ```sh-session
10
+ $ npm install --save-dev @percy/cli
11
+ ```
12
+
13
+ gem install Percy appium package:
14
+
15
+ ```ssh-session
16
+ $ gem install percy-appium-app
17
+ ```
18
+
19
+
20
+ ## Usage
21
+
22
+ This is an example test using the `percy_screenshot` function.
23
+
24
+ ``` ruby
25
+ require 'appium_lib'
26
+ require 'percy-appium-app'
27
+
28
+ username = '<BROWSERSTACK_USERNAME>'
29
+ access_key = '<ACCESS_KEY>'
30
+
31
+ capabilities = {
32
+ 'platformName' => 'android',
33
+ 'platformVersion' => '13.0',
34
+ 'deviceName' => 'Google Pixel 7',
35
+ 'bstack:options' => {
36
+ 'appiumVersion' => '2.0.1'
37
+ },
38
+ 'app' => '<APP LINK>',
39
+ 'appium:percyOptions' => {
40
+ # enabled is default True. This can be used to disable visual testing for certain capabilities
41
+ 'enabled' => true
42
+ }
43
+ }
44
+
45
+ appium_driver = Appium::Driver.new(
46
+ {
47
+ 'caps' => capabilities,
48
+ 'appium_lib' => {
49
+ server_url: "https://#{username}:#{access_key}@hub-cloud.browserstack.com/wd/hub"
50
+ }
51
+ }, true
52
+ )
53
+ driver = appium_driver.start_driver
54
+
55
+ # take a screenshot
56
+ percy_screenshot(driver, 'here is some name')
57
+ ```
58
+
59
+ Running the test above normally will result in the following log:
60
+
61
+ ```sh-session
62
+ [percy] Percy is not running, disabling screenshots
63
+ ```
64
+
65
+ When running with [`percy
66
+ app:exec`](https://github.com/percy/cli/tree/master/packages/cli-exec#app-exec), and your project's
67
+ `PERCY_TOKEN`, a new Percy build will be created and screenshots will be uploaded to your project.
68
+
69
+ ```sh-session
70
+ $ export PERCY_TOKEN=[your-project-token]
71
+ $ percy app:exec -- [ruby test command]
72
+ [percy] Percy has started!
73
+ [percy] Created build #1: https://percy.io/[your-project]
74
+ [percy] Screenshot taken "Ruby example"
75
+ [percy] Stopping percy...
76
+ [percy] Finalized build #1: https://percy.io/[your-project]
77
+ [percy] Done!
78
+ ```
79
+
80
+ ## Configuration
81
+
82
+ `percy_screenshot(driver, name[, **kwargs])`
83
+
84
+ - `driver` (**required**) - A appium driver instance
85
+ - `name` (**required**) - The screenshot name; must be unique to each screenshot
86
+ - `device_name` (**optional**) - The device name used for capturing screenshot
87
+ - `orientation` (**optional**) - Orientation of device while capturing screeenshot; Allowed values [`portrait` | `landscape`]
88
+ - `status_bar_height` (**optional**) - Height of status bar; int
89
+ - `nav_bar_height` (**optional**) - Height of navigation bar; int
90
+ - `fullpage` (**optional**) - [Alpha] Only supported on App Automate driver sessions [ needs @percy/cli 1.20.2+ ]; boolean
91
+ - `screen_lengths` (**optional**) - [Alpha] Max screen lengths for fullPage; int
92
+ - In case scrollview is overlapping with other app elements. Offsets can be provided to reduce the area which needs to be considered for scrolling:
93
+ - `top_scrollview_offset`: (**optional**) - [Alpha] Offset from top of scrollview; int
94
+ - `bottom_scrollview_offset` (**optional**) - [Alpha] Offset from bottom of scrollview; int
95
+ - `full_screen` (**optional**) - Indicate whether app is full screen; boolean [ needs @percy/cli 1.20.2+ ];
96
+ - `scrollable_xpath` (**optional**) - [Alpha] Scrollable element xpath for fullpage [ needs @percy/cli 1.20.2+ ]; string
97
+ - `scrollable_id` (**optional**) - [Alpha] Scrollable element accessibility id for fullpage [ needs @percy/cli 1.20.2+ ]; string
98
+ - `ignore_regions_xpaths` (**optional**) - Elements xpaths that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of string
99
+ - `ignore_region_accessibility_ids` (**optional**) - Elements accessibility_ids that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of string
100
+ - `ignore_region_appium_elements` (**optional**) - Appium elements that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of appium element object
101
+ - `custom_ignore_regions` (**optional**) - Custom locations that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of ignore_region object
102
+ - IgnoreRegion:-
103
+ - Description: This class represents a rectangular area on a screen that needs to be ignored for visual diff.
104
+ - Constructor:
105
+ ```
106
+ init(self, top, bottom, left, right)
107
+ ```
108
+ - Parameters:
109
+ - `top` (int): Top coordinate of the ignore region.
110
+ - `bottom` (int): Bottom coordinate of the ignore region.
111
+ - `left` (int): Left coordinate of the ignore region.
112
+ - `right` (int): Right coordinate of the ignore region.
113
+
114
+ ## Running with Hybrid Apps
115
+
116
+ For a hybrid app, we need to switch to native context before taking screenshot.
117
+
118
+ - Add a helper method similar to following for say flutter based hybrid app:
119
+ ```ruby
120
+ def percy_screenshot_flutter(driver, name: str, **kwargs):
121
+ driver.switch_to.context('NATIVE_APP')
122
+ percy_screenshot(driver, name, **kwargs)
123
+ driver.switch_to.context('FLUTTER')
124
+ end
125
+ ```
126
+
127
+ - Call PercyScreenshotFlutter helper function when you want to take screenshot.
128
+ ```ruby
129
+ percy_screenshot_flutter(driver, name, **kwargs)
130
+ ```
131
+
132
+ > Note:
133
+ >
134
+ > For other hybrid apps the `driver.switch_to.context('FLUTTER')` would change to context that it uses like say WEBVIEW etc.
135
+ >
136
+
137
+ ## Running Percy on Automate
138
+ `percy_screenshot(driver, name, options)` [ needs @percy/cli 1.27.0-beta.0+ ];
139
+ - `driver` (**required**) - A appium driver instance
140
+ - `name` (**required**) - The screenshot name; must be unique to each screenshot
141
+ - `options` (**optional**) - There are various options supported by percy_screenshot to server further functionality.
142
+ - `freeze_animated_image` - Boolean value by default it falls back to `false`, you can pass `true` and percy will freeze image based animations.
143
+ - `freeze_image_by_selectors` -List of selectors. Images will be freezed which are passed using selectors. For this to work `freeze_animated_image` must be set to true.
144
+ - `freeze_image_by_xpaths` - List of xpaths. Images will be freezed which are passed using xpaths. For this to work `freeze_animated_image` must be set to true.
145
+ - `percy_css` - Custom CSS to be added to DOM before the screenshot being taken. Note: This gets removed once the screenshot is taken.
146
+ - `ignore_region_xpaths` - List of xpaths. elements in the DOM can be ignored using xpath
147
+ - `ignore_region_selectors` - List of selectors. elements in the DOM can be ignored using selectors.
148
+ - `ignore_region_appium_elements` - List of appium web-element. elements can be ignored using appium_elements.
149
+ - `custom_ignore_regions` - List of custom objects. elements can be ignored using custom boundaries. Just passing a simple object for it like below.
150
+ - example: ```{"top": 10, "right": 10, "bottom": 120, "left": 10}```
151
+ - In above example it will draw rectangle of ignore region as per given coordinates.
152
+ - `top` (int): Top coordinate of the ignore region.
153
+ - `bottom` (int): Bottom coordinate of the ignore region.
154
+ - `left` (int): Left coordinate of the ignore region.
155
+ - `right` (int): Right coordinate of the ignore region.
156
+ - `consider_region_xpaths` - List of xpaths. elements in the DOM can be considered for diffing and will be ignored by Intelli Ignore using xpaths.
157
+ - `consider_region_selectors` - List of selectors. elements in the DOM can be considered for diffing and will be ignored by Intelli Ignore using selectors.
158
+ - `consider_region_appium_elements` - List of appium web-element. elements can be considered for diffing and will be ignored by Intelli Ignore using appium_elements.
159
+ - `custom_consider_regions` - List of custom objects. elements can be considered for diffing and will be ignored by Intelli Ignore using custom boundaries
160
+ - example:```{"top": 10, "right": 10, "bottom": 120, "left": 10}```
161
+ - In above example it will draw rectangle of consider region will be drawn.
162
+ - Parameters:
163
+ - `top` (int): Top coordinate of the consider region.
164
+ - `bottom` (int): Bottom coordinate of the consider region.
165
+ - `left` (int): Left coordinate of the consider region.
166
+ - `right` (int): Right coordinate of the consider region.
167
+
168
+ ### Creating Percy on automate build
169
+ Note: Automate Percy Token starts with `auto` keyword. The command can be triggered using `exec` keyword.
170
+
171
+ ```sh-session
172
+ $ export PERCY_TOKEN=[your-project-token]
173
+ $ percy exec -- [ruby test command]
174
+ [percy] Percy has started!
175
+ [percy] [Ruby example] : Starting automate screenshot ...
176
+ [percy] Screenshot taken "Ruby example"
177
+ [percy] Stopping percy...
178
+ [percy] Finalized build #1: https://percy.io/[your-project]
179
+ [percy] Done!
180
+ ```
181
+
182
+ Refer to docs here: [Percy on Automate](https://docs.percy.io/docs/integrate-functional-testing-with-visual-testing)
183
+
184
+ ### Migrating Config
185
+
186
+ If you have a previous Percy configuration file, migrate it to the newest version with the
187
+ [`config:migrate`](https://github.com/percy/cli/tree/master/packages/cli-config#percy-configmigrate-filepath-output) command:
188
+
189
+ ```sh-session
190
+ $ percy config:migrate
191
+ ```
data/percy/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Percy
4
- VERSION = '0.0.2'.freeze
4
+ VERSION = '0.0.3'.freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percy-appium-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - BroswerStack