percy-appium-app 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +193 -1
- data/percy/lib/app_percy.rb +0 -1
- data/percy/lib/cli_wrapper.rb +11 -5
- data/percy/lib/percy_automate.rb +3 -2
- data/percy/providers/app_automate.rb +7 -5
- data/percy/providers/generic_provider.rb +4 -3
- data/percy/version.rb +1 -1
- data/specs/screenshot.rb +83 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7a335595865863cc2116b953c51d39b8665116c6f05589273f3211e4bf5fef8
|
4
|
+
data.tar.gz: 468688dfe18390bb7068e8fa479e5e9a7ff7b739ef5759e2ddc1a5641c9a59c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9beee657ec15a65ee967f60295dac3d5caebc8f6355c5ee1f026dc2faba2056a7ccade079a88f0d81c51d3efeada4b178ac249415cb5fb7ee26f38c05dc2995
|
7
|
+
data.tar.gz: 3ba4e693b137e7d84109408d22b7ff6372f888a6b30ef4295a9a61974d8f674d746e8989209c4c7eb887a524b866a0be0810fb10ebf120f430ac10ffecb256d3
|
data/README.md
CHANGED
@@ -1 +1,193 @@
|
|
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
|
+
- `sync` (**optional**) - Waits for screenshot to be processed and gives the processed result of screenshot [needs @percy/cli v1.28.0-beta.0+]; boolean
|
97
|
+
- `scrollable_xpath` (**optional**) - [Alpha] Scrollable element xpath for fullpage [ needs @percy/cli 1.20.2+ ]; string
|
98
|
+
- `scrollable_id` (**optional**) - [Alpha] Scrollable element accessibility id for fullpage [ needs @percy/cli 1.20.2+ ]; string
|
99
|
+
- `ignore_regions_xpaths` (**optional**) - Elements xpaths that user want to ignore in visual diff [ needs @percy/cli 1.23.0+ ]; list of string
|
100
|
+
- `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
|
101
|
+
- `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
|
102
|
+
- `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
|
103
|
+
- IgnoreRegion:-
|
104
|
+
- Description: This class represents a rectangular area on a screen that needs to be ignored for visual diff.
|
105
|
+
- Constructor:
|
106
|
+
```
|
107
|
+
init(self, top, bottom, left, right)
|
108
|
+
```
|
109
|
+
- Parameters:
|
110
|
+
- `top` (int): Top coordinate of the ignore region.
|
111
|
+
- `bottom` (int): Bottom coordinate of the ignore region.
|
112
|
+
- `left` (int): Left coordinate of the ignore region.
|
113
|
+
- `right` (int): Right coordinate of the ignore region.
|
114
|
+
|
115
|
+
## Running with Hybrid Apps
|
116
|
+
|
117
|
+
For a hybrid app, we need to switch to native context before taking screenshot.
|
118
|
+
|
119
|
+
- Add a helper method similar to following for say flutter based hybrid app:
|
120
|
+
```ruby
|
121
|
+
def percy_screenshot_flutter(driver, name: str, **kwargs):
|
122
|
+
driver.switch_to.context('NATIVE_APP')
|
123
|
+
percy_screenshot(driver, name, **kwargs)
|
124
|
+
driver.switch_to.context('FLUTTER')
|
125
|
+
end
|
126
|
+
```
|
127
|
+
|
128
|
+
- Call PercyScreenshotFlutter helper function when you want to take screenshot.
|
129
|
+
```ruby
|
130
|
+
percy_screenshot_flutter(driver, name, **kwargs)
|
131
|
+
```
|
132
|
+
|
133
|
+
> Note:
|
134
|
+
>
|
135
|
+
> For other hybrid apps the `driver.switch_to.context('FLUTTER')` would change to context that it uses like say WEBVIEW etc.
|
136
|
+
>
|
137
|
+
|
138
|
+
## Running Percy on Automate
|
139
|
+
`percy_screenshot(driver, name, options)` [ needs @percy/cli 1.27.0-beta.0+ ];
|
140
|
+
- `driver` (**required**) - A appium driver instance
|
141
|
+
- `name` (**required**) - The screenshot name; must be unique to each screenshot
|
142
|
+
- `options` (**optional**) - There are various options supported by percy_screenshot to server further functionality.
|
143
|
+
- `sync` - Boolean value by default it falls back to `false`, Gives the processed result around screenshot [From CLI v1.28.0-beta.0+].
|
144
|
+
- `freeze_animated_image` - Boolean value by default it falls back to `false`, you can pass `true` and percy will freeze image based animations.
|
145
|
+
- `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.
|
146
|
+
- `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.
|
147
|
+
- `percy_css` - Custom CSS to be added to DOM before the screenshot being taken. Note: This gets removed once the screenshot is taken.
|
148
|
+
- `ignore_region_xpaths` - List of xpaths. elements in the DOM can be ignored using xpath
|
149
|
+
- `ignore_region_selectors` - List of selectors. elements in the DOM can be ignored using selectors.
|
150
|
+
- `ignore_region_appium_elements` - List of appium web-element. elements can be ignored using appium_elements.
|
151
|
+
- `custom_ignore_regions` - List of custom objects. elements can be ignored using custom boundaries. Just passing a simple object for it like below.
|
152
|
+
- example: ```{"top": 10, "right": 10, "bottom": 120, "left": 10}```
|
153
|
+
- In above example it will draw rectangle of ignore region as per given coordinates.
|
154
|
+
- `top` (int): Top coordinate of the ignore region.
|
155
|
+
- `bottom` (int): Bottom coordinate of the ignore region.
|
156
|
+
- `left` (int): Left coordinate of the ignore region.
|
157
|
+
- `right` (int): Right coordinate of the ignore region.
|
158
|
+
- `consider_region_xpaths` - List of xpaths. elements in the DOM can be considered for diffing and will be ignored by Intelli Ignore using xpaths.
|
159
|
+
- `consider_region_selectors` - List of selectors. elements in the DOM can be considered for diffing and will be ignored by Intelli Ignore using selectors.
|
160
|
+
- `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.
|
161
|
+
- `custom_consider_regions` - List of custom objects. elements can be considered for diffing and will be ignored by Intelli Ignore using custom boundaries
|
162
|
+
- example:```{"top": 10, "right": 10, "bottom": 120, "left": 10}```
|
163
|
+
- In above example it will draw rectangle of consider region will be drawn.
|
164
|
+
- Parameters:
|
165
|
+
- `top` (int): Top coordinate of the consider region.
|
166
|
+
- `bottom` (int): Bottom coordinate of the consider region.
|
167
|
+
- `left` (int): Left coordinate of the consider region.
|
168
|
+
- `right` (int): Right coordinate of the consider region.
|
169
|
+
|
170
|
+
### Creating Percy on automate build
|
171
|
+
Note: Automate Percy Token starts with `auto` keyword. The command can be triggered using `exec` keyword.
|
172
|
+
|
173
|
+
```sh-session
|
174
|
+
$ export PERCY_TOKEN=[your-project-token]
|
175
|
+
$ percy exec -- [ruby test command]
|
176
|
+
[percy] Percy has started!
|
177
|
+
[percy] [Ruby example] : Starting automate screenshot ...
|
178
|
+
[percy] Screenshot taken "Ruby example"
|
179
|
+
[percy] Stopping percy...
|
180
|
+
[percy] Finalized build #1: https://percy.io/[your-project]
|
181
|
+
[percy] Done!
|
182
|
+
```
|
183
|
+
|
184
|
+
Refer to docs here: [Percy on Automate](https://docs.percy.io/docs/integrate-functional-testing-with-visual-testing)
|
185
|
+
|
186
|
+
### Migrating Config
|
187
|
+
|
188
|
+
If you have a previous Percy configuration file, migrate it to the newest version with the
|
189
|
+
[`config:migrate`](https://github.com/percy/cli/tree/master/packages/cli-config#percy-configmigrate-filepath-output) command:
|
190
|
+
|
191
|
+
```sh-session
|
192
|
+
$ percy config:migrate
|
193
|
+
```
|
data/percy/lib/app_percy.rb
CHANGED
data/percy/lib/cli_wrapper.rb
CHANGED
@@ -49,13 +49,14 @@ module Percy
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def post_screenshots(name, tag, tiles, external_debug_url = nil, ignored_elements_data = nil,
|
52
|
-
considered_elements_data = nil)
|
53
|
-
body = request_body(name, tag, tiles, external_debug_url, ignored_elements_data, considered_elements_data)
|
52
|
+
considered_elements_data = nil, sync = nil)
|
53
|
+
body = request_body(name, tag, tiles, external_debug_url, ignored_elements_data, considered_elements_data, sync)
|
54
54
|
body['client_info'] = Percy::Environment.get_client_info
|
55
55
|
body['environment_info'] = Percy::Environment.get_env_info
|
56
56
|
|
57
57
|
uri = URI("#{PERCY_CLI_API}/percy/comparison")
|
58
58
|
http = Net::HTTP.new(uri.host, uri.port)
|
59
|
+
http.read_timeout = 600 # seconds
|
59
60
|
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
60
61
|
request.body = body.to_json
|
61
62
|
|
@@ -104,7 +105,11 @@ module Percy
|
|
104
105
|
body['environment_info'] = Percy::Environment.get_env_info
|
105
106
|
|
106
107
|
uri = URI("#{PERCY_CLI_API}/percy/automateScreenshot")
|
107
|
-
|
108
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
109
|
+
http.read_timeout = 600 # seconds
|
110
|
+
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
111
|
+
request.body = body.to_json
|
112
|
+
response = http.request(request)
|
108
113
|
|
109
114
|
# Handle errors
|
110
115
|
raise CLIException, "Error: #{response.message}" unless response.is_a?(Net::HTTPSuccess)
|
@@ -119,7 +124,7 @@ module Percy
|
|
119
124
|
data
|
120
125
|
end
|
121
126
|
|
122
|
-
def request_body(name, tag, tiles, external_debug_url, ignored_elements_data, considered_elements_data)
|
127
|
+
def request_body(name, tag, tiles, external_debug_url, ignored_elements_data, considered_elements_data, sync)
|
123
128
|
tiles = tiles.map(&:to_h)
|
124
129
|
{
|
125
130
|
'name' => name,
|
@@ -127,7 +132,8 @@ module Percy
|
|
127
132
|
'tiles' => tiles,
|
128
133
|
'ignored_elements_data' => ignored_elements_data,
|
129
134
|
'external_debug_url' => external_debug_url,
|
130
|
-
'considered_elements_data' => considered_elements_data
|
135
|
+
'considered_elements_data' => considered_elements_data,
|
136
|
+
'sync' => sync
|
131
137
|
}
|
132
138
|
end
|
133
139
|
end
|
data/percy/lib/percy_automate.rb
CHANGED
@@ -43,7 +43,7 @@ module Percy
|
|
43
43
|
'consider_region_elements' => consider_region_elements
|
44
44
|
}
|
45
45
|
|
46
|
-
Percy::CLIWrapper.new.post_poa_screenshots(
|
46
|
+
response = Percy::CLIWrapper.new.post_poa_screenshots(
|
47
47
|
name,
|
48
48
|
metadata.session_id,
|
49
49
|
metadata.command_executor_url,
|
@@ -51,11 +51,12 @@ module Percy
|
|
51
51
|
metadata.session_capabilities,
|
52
52
|
options.merge(additional_options)
|
53
53
|
)
|
54
|
+
|
55
|
+
response['data']
|
54
56
|
rescue StandardError => e
|
55
57
|
log("Could not take Screenshot '#{name}'")
|
56
58
|
log(e.message, on_debug: true)
|
57
59
|
end
|
58
|
-
nil
|
59
60
|
end
|
60
61
|
end
|
61
62
|
end
|
@@ -29,9 +29,10 @@ module Percy
|
|
29
29
|
begin
|
30
30
|
response = super(name, **kwargs)
|
31
31
|
percy_screenshot_url = response.fetch('link', '')
|
32
|
-
execute_percy_screenshot_end(name, percy_screenshot_url, 'success')
|
32
|
+
execute_percy_screenshot_end(name, percy_screenshot_url, 'success', kwargs.fetch('sync', nil))
|
33
|
+
response['data']
|
33
34
|
rescue StandardError => e
|
34
|
-
execute_percy_screenshot_end(name, percy_screenshot_url, 'failure', e.message)
|
35
|
+
execute_percy_screenshot_end(name, percy_screenshot_url, 'failure', kwargs.fetch('sync', nil), e.message)
|
35
36
|
raise e
|
36
37
|
end
|
37
38
|
end
|
@@ -104,14 +105,15 @@ module Percy
|
|
104
105
|
end
|
105
106
|
end
|
106
107
|
|
107
|
-
def execute_percy_screenshot_end(name, percy_screenshot_url, status, status_message = nil)
|
108
|
+
def execute_percy_screenshot_end(name, percy_screenshot_url, status, sync = nil, status_message = nil)
|
108
109
|
request_body = {
|
109
110
|
action: 'percyScreenshot',
|
110
111
|
arguments: {
|
111
112
|
state: 'end',
|
112
113
|
percyScreenshotUrl: percy_screenshot_url,
|
113
114
|
name: name,
|
114
|
-
status: status
|
115
|
+
status: status,
|
116
|
+
sync: sync
|
115
117
|
}
|
116
118
|
}
|
117
119
|
request_body[:arguments][:statusMessage] = status_message if status_message
|
@@ -158,4 +160,4 @@ module Percy
|
|
158
160
|
end
|
159
161
|
end
|
160
162
|
end
|
161
|
-
end
|
163
|
+
end
|
@@ -42,8 +42,9 @@ module Percy
|
|
42
42
|
custom_locations: kwargs.fetch(:custom_consider_regions, [])
|
43
43
|
)
|
44
44
|
}
|
45
|
+
sync = kwargs.fetch(:sync, nil)
|
45
46
|
|
46
|
-
_post_screenshots(name, tag, tiles, get_debug_url, ignore_regions, consider_regions)
|
47
|
+
_post_screenshots(name, tag, tiles, get_debug_url, ignore_regions, consider_regions, sync)
|
47
48
|
end
|
48
49
|
|
49
50
|
def _get_tag(**kwargs)
|
@@ -93,8 +94,8 @@ module Percy
|
|
93
94
|
elements_array
|
94
95
|
end
|
95
96
|
|
96
|
-
def _post_screenshots(name, tag, tiles, debug_url, ignored_regions, considered_regions)
|
97
|
-
Percy::CLIWrapper.new.post_screenshots(name, tag, tiles, debug_url, ignored_regions, considered_regions)
|
97
|
+
def _post_screenshots(name, tag, tiles, debug_url, ignored_regions, considered_regions, sync)
|
98
|
+
Percy::CLIWrapper.new.post_screenshots(name, tag, tiles, debug_url, ignored_regions, considered_regions, sync)
|
98
99
|
end
|
99
100
|
|
100
101
|
def _write_screenshot(png_bytes, directory)
|
data/percy/version.rb
CHANGED
data/specs/screenshot.rb
CHANGED
@@ -6,7 +6,7 @@ require 'webmock/minitest'
|
|
6
6
|
require 'appium_lib'
|
7
7
|
require 'webrick'
|
8
8
|
|
9
|
-
require_relative '../percy/
|
9
|
+
require_relative '../percy/percy-appium-app'
|
10
10
|
require_relative '../percy/lib/app_percy'
|
11
11
|
require_relative 'mocks/mock_methods'
|
12
12
|
|
@@ -54,14 +54,14 @@ def mock_healthcheck(fail: false, fail_how: 'error', type: 'Percy::AppPercy')
|
|
54
54
|
.to_return(status: health_status, body: health_body, headers: health_headers)
|
55
55
|
end
|
56
56
|
|
57
|
-
def mock_screenshot(fail: false)
|
57
|
+
def mock_screenshot(fail: false, data: false)
|
58
58
|
stub_request(:post, 'http://localhost:5338/percy/comparison')
|
59
|
-
.to_return(body: "{\"success\": #{fail ? 'false, "error": "test"' : 'true'}}", status: (fail ? 500 : 200))
|
59
|
+
.to_return(body: "{\"success\": #{fail ? 'false, "error": "test"' : 'true'} #{data ? ',"data": "sync-data"' : ""}}", status: (fail ? 500 : 200))
|
60
60
|
end
|
61
61
|
|
62
|
-
def mock_poa_screenshot(fail: false)
|
62
|
+
def mock_poa_screenshot(fail: false, data: false)
|
63
63
|
stub_request(:post, 'http://localhost:5338/percy/automateScreenshot')
|
64
|
-
.to_return(body: "{\"success\": #{fail ? 'false, "error": "test"' : 'true'}}", status: (fail ? 500 : 200))
|
64
|
+
.to_return(body: "{\"success\": #{fail ? 'false, "error": "test"' : 'true'} #{data ? ',"data": "sync-data"' : ""}}", status: (fail ? 500 : 200))
|
65
65
|
end
|
66
66
|
|
67
67
|
def mock_session_request
|
@@ -204,6 +204,37 @@ class TestPercyScreenshot < Minitest::Test
|
|
204
204
|
assert_equal(['Consider_Dummy_id'], s2['options']['consider_region_elements'])
|
205
205
|
end
|
206
206
|
|
207
|
+
def test_posts_screenshot_poa_with_sync
|
208
|
+
mock_healthcheck(type: 'automate')
|
209
|
+
mock_poa_screenshot(data: true)
|
210
|
+
mock_session_request
|
211
|
+
|
212
|
+
driver = Minitest::Mock.new
|
213
|
+
@bridge = Minitest::Mock.new
|
214
|
+
@http = Minitest::Mock.new
|
215
|
+
@server_url = Minitest::Mock.new
|
216
|
+
|
217
|
+
driver.expect(:is_a?, true, [Appium::Core::Base::Driver])
|
218
|
+
driver.expect(:desired_capabilities, { 'key' => 'value' })
|
219
|
+
driver.expect(:instance_variable_get, @bridge, [:@bridge])
|
220
|
+
@http.expect(:instance_variable_get, @server_url, [:@server_url])
|
221
|
+
@bridge.expect(:instance_variable_get, @http, [:@http])
|
222
|
+
@server_url.expect(:to_s, 'https://hub-cloud.browserstack.com/wd/hub')
|
223
|
+
|
224
|
+
10.times do
|
225
|
+
driver.expect(:session_id, 'Dummy_session_id')
|
226
|
+
end
|
227
|
+
2.times do
|
228
|
+
driver.expect(:capabilities, { 'key' => 'value' })
|
229
|
+
end
|
230
|
+
@mock_webdriver.expect(:capabilities, { 'key' => 'value' })
|
231
|
+
|
232
|
+
res = percy_screenshot(driver, 'Snapshot 1', options: { sync: true })
|
233
|
+
|
234
|
+
assert_equal('sync-data', res)
|
235
|
+
assert_equal('/percy/automateScreenshot', @requests.last.uri.path)
|
236
|
+
end
|
237
|
+
|
207
238
|
def test_posts_multiple_screenshots_to_the_local_percy_server
|
208
239
|
mock_healthcheck
|
209
240
|
mock_screenshot
|
@@ -256,6 +287,53 @@ class TestPercyScreenshot < Minitest::Test
|
|
256
287
|
assert_match(%r{ruby/\d+\.\d+\.\d+}, body['environment_info'][1])
|
257
288
|
end
|
258
289
|
|
290
|
+
def test_post_screenshot_with_sync
|
291
|
+
mock_healthcheck
|
292
|
+
mock_screenshot(data: true)
|
293
|
+
|
294
|
+
driver = Minitest::Mock.new
|
295
|
+
|
296
|
+
driver.expect(:is_a?, true, [Appium::Core::Base::Driver])
|
297
|
+
driver.expect(:instance_variable_get, @bridge, [:@bridge])
|
298
|
+
@http.expect(:instance_variable_get, @server_url, [:@server_url])
|
299
|
+
@bridge.expect(:instance_variable_get, @http, [:@http])
|
300
|
+
@server_url.expect(:to_s, 'https://hub-cloud.browserstack.com/wd/hub')
|
301
|
+
|
302
|
+
5.times do
|
303
|
+
driver.expect(:session_id, 'Dummy_session_id')
|
304
|
+
end
|
305
|
+
|
306
|
+
13.times do
|
307
|
+
driver.expect(:capabilities, get_android_capabilities)
|
308
|
+
end
|
309
|
+
|
310
|
+
3.times do
|
311
|
+
driver.expect(
|
312
|
+
:execute_script,
|
313
|
+
'{"success":true,"result":"[{\"sha\":\"sha-something\",\"status_bar\":null'\
|
314
|
+
',\"nav_bar\":null,\"header_height\":0,\"footer_height\":0,\"index\":0}]"}',
|
315
|
+
[String]
|
316
|
+
)
|
317
|
+
end
|
318
|
+
|
319
|
+
2.times do
|
320
|
+
driver.expect(:get_system_bars, {
|
321
|
+
'statusBar' => { 'height' => 10, 'width' => 20 },
|
322
|
+
'navigationBar' => { 'height' => 10, 'width' => 20 }
|
323
|
+
})
|
324
|
+
end
|
325
|
+
|
326
|
+
res = percy_screenshot(driver, 'screenshot 2', sync: true)
|
327
|
+
|
328
|
+
assert_equal('sync-data', res)
|
329
|
+
assert_equal('/percy/comparison', @requests.last.uri.path)
|
330
|
+
|
331
|
+
body = JSON.parse(@requests[-1].body)
|
332
|
+
assert_match(%r{percy-appium-app/\d+}, body['client_info'])
|
333
|
+
assert_match(%r{appium/\d+}, body['environment_info'][0])
|
334
|
+
assert_match(%r{ruby/\d+\.\d+\.\d+}, body['environment_info'][1])
|
335
|
+
end
|
336
|
+
|
259
337
|
def test_ignore_region_screenshots_to_the_local_percy_server
|
260
338
|
mock_healthcheck
|
261
339
|
mock_screenshot
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: percy-appium-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BroswerStack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appium_lib
|
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
201
|
- !ruby/object:Gem::Version
|
202
202
|
version: '0'
|
203
203
|
requirements: []
|
204
|
-
rubygems_version: 3.
|
204
|
+
rubygems_version: 3.1.6
|
205
205
|
signing_key:
|
206
206
|
specification_version: 4
|
207
207
|
summary: Percy visual testing for Ruby Appium Mobile Apps
|