@applitools/eyes-selenium 4.67.5 → 4.68.1
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.
- package/CHANGELOG.md +34 -0
- package/README.md +3 -1012
- package/package.json +3 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.68.1](https://github.com/applitools/eyes.sdk.javascript1/compare/js/eyes-selenium@4.68.0...js/eyes-selenium@4.68.1) (2023-09-12)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Dependencies
|
|
7
|
+
|
|
8
|
+
* @applitools/core bumped to 3.10.4
|
|
9
|
+
#### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* update dom-snapshot to support xml pages and parens inside css URLs ([0715d56](https://github.com/applitools/eyes.sdk.javascript1/commit/0715d56c675b23be017c1985cbba3a51aba052b1))
|
|
12
|
+
* @applitools/eyes bumped to 1.8.4
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [4.68.0](https://github.com/applitools/eyes.sdk.javascript1/compare/js/eyes-selenium-v4.67.6...js/eyes-selenium@4.68.0) (2023-09-11)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* rework log event on opent eyes ([#1842](https://github.com/applitools/eyes.sdk.javascript1/issues/1842)) ([532756b](https://github.com/applitools/eyes.sdk.javascript1/commit/532756b75c1023967c3781316148c890dbcfaac8))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Code Refactoring
|
|
24
|
+
|
|
25
|
+
* refactored spec driver interface ([#1839](https://github.com/applitools/eyes.sdk.javascript1/issues/1839)) ([aa49ec2](https://github.com/applitools/eyes.sdk.javascript1/commit/aa49ec2a7d14b8529acc3a8a4c2baecfa113d98a))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Dependencies
|
|
29
|
+
|
|
30
|
+
* @applitools/core bumped to 3.10.3
|
|
31
|
+
#### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* suppport coded regions with layoutBreakpoints reload ([7903347](https://github.com/applitools/eyes.sdk.javascript1/commit/79033472b9475992a44cf3828ff334c958ae2066))
|
|
34
|
+
* @applitools/eyes bumped to 1.8.3
|
|
35
|
+
|
|
36
|
+
|
|
3
37
|
## [4.67.5](https://github.com/applitools/eyes.sdk.javascript1/compare/js/eyes-selenium@4.67.4...js/eyes-selenium@4.67.5) (2023-09-04)
|
|
4
38
|
|
|
5
39
|
|
package/README.md
CHANGED
|
@@ -7,1015 +7,6 @@
|
|
|
7
7
|
</div>
|
|
8
8
|
<br/>
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- [
|
|
13
|
-
- [Applitools API key](#applitools-api-key)
|
|
14
|
-
- [Usage](#usage)
|
|
15
|
-
- [Getting started with the API](#getting-started-with-the-api)
|
|
16
|
-
- [Eyes constructor](#eyes-constructor)
|
|
17
|
-
- [open](#open)
|
|
18
|
-
- [Visual tests and baselines](#visual-tests-and-baselines)
|
|
19
|
-
- [Batches](#batches)
|
|
20
|
-
- [check](#check)
|
|
21
|
-
- [`checkSettings`](#checksettings)
|
|
22
|
-
- [Page screenshot](#page-screenshot)
|
|
23
|
-
- [Region screenshot](#region-screenshot)
|
|
24
|
-
- [Switching into frames](#switching-into-frames)
|
|
25
|
-
- [Ignore Regions](#ignore-regions)
|
|
26
|
-
- [Floating Regions](#floating-regions)
|
|
27
|
-
- [Content/Strict/Layout Regions](#contentstrictlayout-regions)
|
|
28
|
-
- [Accessiblity Regions](#accessiblity-regions)
|
|
29
|
-
- [Scroll root element](#scroll-root-element)
|
|
30
|
-
- [Tag (`withName`)](#tag-withname)
|
|
31
|
-
- [Variation group ID](#variation-group-id)
|
|
32
|
-
- [Lazy loading (`lazyLoad`)](#lazy-loading-lazyload)
|
|
33
|
-
- [Density metrics](#density-metrics-densitymetrics)
|
|
34
|
-
- [Other checkSettings configuration](#other-checksettings-configuration)
|
|
35
|
-
- [close](#close)
|
|
36
|
-
- [Runners](#runners)
|
|
37
|
-
- [Purpose of runners](#purpose-of-runners)
|
|
38
|
-
- [1. Use the Ultrafast grid](#1-use-the-ultrafast-grid)
|
|
39
|
-
- [2. Manage tests across multiple `Eyes` instances](#2-manage-tests-across-multiple-eyes-instances)
|
|
40
|
-
- [Visual locators](#visual-locators)
|
|
41
|
-
- [](#)
|
|
42
|
-
- [Recipes for common tasks](#recipes-for-common-tasks)
|
|
43
|
-
- [Configure Server URL](#configure-server-url)
|
|
44
|
-
- [Configure Proxy](#configure-proxy)
|
|
45
|
-
- [Make every visual test correspond to a functional test](#make-every-visual-test-correspond-to-a-functional-test)
|
|
46
|
-
- [Organize tests in batches](#organize-tests-in-batches)
|
|
47
|
-
- [Method 1: environment variable](#method-1-environment-variable)
|
|
48
|
-
- [Method 2: `eyes.setBatch`](#method-2-eyessetbatch)
|
|
49
|
-
- [Stitch mode](#stitch-mode)
|
|
50
|
-
- [Background information](#background-information)
|
|
51
|
-
- [1. Stitch mode: Scroll](#1-stitch-mode-scroll)
|
|
52
|
-
- [2. Stitch mode: CSS](#2-stitch-mode-css)
|
|
53
|
-
- [Stitch overlap](#stitch-overlap)
|
|
54
|
-
- [Match level](#match-level)
|
|
55
|
-
- [Ignore displacements](#ignore-displacements)
|
|
56
|
-
- [Test properties](#test-properties)
|
|
57
|
-
- [Test results](#test-results)
|
|
58
|
-
- [Logging](#logging)
|
|
59
|
-
- [Configuring browsers for the Ultrafast grid](#configuring-browsers-for-the-ultrafast-grid)
|
|
60
|
-
- [Desktop browsers](#desktop-browsers)
|
|
61
|
-
- [Chrome device emulation](#chrome-device-emulation)
|
|
62
|
-
- [iOS device](#ios-device)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
## Installation
|
|
66
|
-
|
|
67
|
-
Install Eyes-Selenium as a local dev dependency in your tested project:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
npm i -D @applitools/eyes-selenium
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Applitools API key
|
|
74
|
-
|
|
75
|
-
In order to authenticate via the Applitools server, you need to supply the Eyes-Selenium SDK with the API key you got from Applitools. Read more about how to obtain the API key [here](https://applitools.com/docs/topics/overview/obtain-api-key.html).
|
|
76
|
-
|
|
77
|
-
To do this, set the environment variable `APPLITOOLS_API_KEY` to the API key before running your tests.
|
|
78
|
-
For example, on Linux/Mac:
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
export APPLITOOLS_API_KEY=<your_key>
|
|
82
|
-
npm test
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
And on Windows:
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
set APPLITOOLS_API_KEY=<your_key>
|
|
89
|
-
npx test
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
It's also possible to set the API key programmatically like so:
|
|
93
|
-
|
|
94
|
-
```js
|
|
95
|
-
eyes.setApiKey('<your API key>')
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## Usage
|
|
99
|
-
|
|
100
|
-
After defining the API key, you will be able to use commands from Eyes-Selenium in your tests to take screenshots and use Applitools Eyes to manage them.
|
|
101
|
-
|
|
102
|
-
For example:
|
|
103
|
-
|
|
104
|
-
```js
|
|
105
|
-
const {Eyes, Target} = require('@applitools/eyes-selenium')
|
|
106
|
-
|
|
107
|
-
describe('My first visual test', function() {
|
|
108
|
-
it('should check the Applitools website', async function() {
|
|
109
|
-
browser.get('https://applitools.com');
|
|
110
|
-
|
|
111
|
-
const eyes = new Eyes();
|
|
112
|
-
await eyes.open(browser, "applitools.com website", "My first Selenium test!")
|
|
113
|
-
await eyes.check('home page', Target.window().fully())
|
|
114
|
-
await eyes.close()
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
## Getting started with the API
|
|
120
|
-
|
|
121
|
-
### Eyes constructor
|
|
122
|
-
|
|
123
|
-
Creates an instance of `Eyes`, which then exposes methods to run and configure visual tests.
|
|
124
|
-
|
|
125
|
-
```js
|
|
126
|
-
const eyes = new Eyes(runner)
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
- `runner` - A runner instance which manages tests across multiple `Eyes` instances. The runner can be an instance of either a `ClassicRunenr` or a `VisualGridRunner`. For more information, see the [Runners](#runners) section below.
|
|
130
|
-
|
|
131
|
-
### open
|
|
132
|
-
|
|
133
|
-
Creates an Applitools test.
|
|
134
|
-
This will start a session with the Applitools server.
|
|
135
|
-
|
|
136
|
-
```js
|
|
137
|
-
eyes.open(browser, appName, testName, viewportSize)
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
#### Visual tests and baselines
|
|
141
|
-
|
|
142
|
-
By using the `open`/`check`/`close` methods on `Eyes`, you are creating visual tests in Applitools Eyes. A visual test is a sequence of screenshots, compared with a baseline. The baseline is also a sequence of screenshots. The specific baseline to compare against is found by using the values for:
|
|
143
|
-
|
|
144
|
-
1. Browser
|
|
145
|
-
2. Operating system
|
|
146
|
-
3. App name
|
|
147
|
-
4. Test name
|
|
148
|
-
5. Viewport size
|
|
149
|
-
|
|
150
|
-
The baseline is created automatically when running a test with specific values for these 5 parameters for the first time. For example, you run a test with **Chrome** on **OS X** and specify the **app name**, **test name** and **viewport size** via `eyes.open(t, 'some app', 'some test', {width: 1200, height: 800})`. The first time the test runs with these parameters, a baseline will be created. Any subsequent execution with the same values will compare screenshots against this baseline. The test will actually be created after running `eyes.close`, and the results of the test are returned as a `TestResults` object.
|
|
151
|
-
|
|
152
|
-
_For more information, visit our documentation page:
|
|
153
|
-
https://applitools.com/docs/topics/general-concepts/how-eyes-compares-checkpoints.html_
|
|
154
|
-
|
|
155
|
-
#### Batches
|
|
156
|
-
|
|
157
|
-
It's possible to aggregate tests that are run in different processes, or in different Eyes instances, under the same batch. This is done by providing the same batch ID to these tests.
|
|
158
|
-
|
|
159
|
-
For instructions, see the [Organize tests in batches](#organize-tests-in-batches) section below.
|
|
160
|
-
|
|
161
|
-
_For more information, visit our documentation page:
|
|
162
|
-
https://applitools.com/docs/topics/working-with-test-batches/working-with-test-batches-in-overview.html_
|
|
163
|
-
|
|
164
|
-
### check
|
|
165
|
-
|
|
166
|
-
Generates a screenshot of the current page and add it to the Applitools Test.
|
|
167
|
-
|
|
168
|
-
```js
|
|
169
|
-
eyes.check(checkSettings)
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
#### `checkSettings`
|
|
173
|
-
|
|
174
|
-
Holds the checkpoint's configuration. This is defined using a fluent API, starting with `Target`.
|
|
175
|
-
|
|
176
|
-
##### Page screenshot
|
|
177
|
-
|
|
178
|
-
- For taking a viewport screenshot, call `Target.window()`.
|
|
179
|
-
- For a full page screenshot, call `Target.window().fully()`.
|
|
180
|
-
|
|
181
|
-
##### Region screenshot
|
|
182
|
-
|
|
183
|
-
To take an element screenshot, it's possible to specify either a locator or the element representation itself. For example:
|
|
184
|
-
|
|
185
|
-
```js
|
|
186
|
-
// region by locator
|
|
187
|
-
const locator = by.css('.banner')
|
|
188
|
-
eyes.check(Target.region(locator))
|
|
189
|
-
|
|
190
|
-
// region by element
|
|
191
|
-
const el = element(locator)
|
|
192
|
-
eyes.check(Target.region(el))
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
Passing a string is interpreted as a css selector:
|
|
196
|
-
|
|
197
|
-
```js
|
|
198
|
-
// region by css selector
|
|
199
|
-
eyes.check(Target.region('.banner'))
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
It's also possible to specify the absolute coordinates for the desired region:
|
|
203
|
-
|
|
204
|
-
```js
|
|
205
|
-
// region by coordinates
|
|
206
|
-
eyes.check(
|
|
207
|
-
Target.region({left: 10, top: 20, width: 200, height: 80})
|
|
208
|
-
)
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
For all the above options, it's possible to specify `.fully()` in order to take the entire content of an element that can be scrolled.
|
|
212
|
-
|
|
213
|
-
##### Switching into frames
|
|
214
|
-
|
|
215
|
-
For taking screenshots of elements inside iframes, it's possible to specify the frame using the `Target.frame` fluent API. For example:
|
|
216
|
-
|
|
217
|
-
```js
|
|
218
|
-
// element inside frame
|
|
219
|
-
eyes.check(
|
|
220
|
-
Target.frame('frame-1').region(by.css('.element-inside frame')
|
|
221
|
-
)
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
It's possible to take a screenshot of the entire frame:
|
|
225
|
-
|
|
226
|
-
```js
|
|
227
|
-
// entire frame
|
|
228
|
-
eyes.check(
|
|
229
|
-
Target.frame('frame-1').fully()
|
|
230
|
-
)
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
Multiple frame calls can be made, thus creating a "frame chain". For example:
|
|
234
|
-
|
|
235
|
-
```js
|
|
236
|
-
// element inside nested frames
|
|
237
|
-
eyes.check(
|
|
238
|
-
Target.frame('frame-1').frame('frame-1-1').region(by.css('.nested-element'))
|
|
239
|
-
)
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
##### Ignore Regions
|
|
243
|
-
|
|
244
|
-
<!-- TODO add explanation -->
|
|
245
|
-
|
|
246
|
-
```js
|
|
247
|
-
// single region
|
|
248
|
-
eyes.check(
|
|
249
|
-
'viewport screenshot with ignore region',
|
|
250
|
-
Target
|
|
251
|
-
.window()
|
|
252
|
-
.ignoreRegion('.dynamic-content-here')
|
|
253
|
-
)
|
|
254
|
-
|
|
255
|
-
// multiple regions
|
|
256
|
-
eyes.check(
|
|
257
|
-
'viewport screenshot with ignore region',
|
|
258
|
-
Target
|
|
259
|
-
.window()
|
|
260
|
-
.ignoreRegions('.dynamic-content-here', someElement, someCoordinates)
|
|
261
|
-
)
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
Possible input types are:
|
|
265
|
-
|
|
266
|
-
- string (interpreted as css selector)
|
|
267
|
-
- `by` locator
|
|
268
|
-
- element
|
|
269
|
-
- coordinates (`{left, top, width, height}`)
|
|
270
|
-
|
|
271
|
-
##### Floating Regions
|
|
272
|
-
|
|
273
|
-
<!-- TODO add explanation -->
|
|
274
|
-
|
|
275
|
-
```js
|
|
276
|
-
// viewport screenshot with floating region
|
|
277
|
-
eyes.check(
|
|
278
|
-
Target
|
|
279
|
-
.window()
|
|
280
|
-
.floatingRegion('.floating-area', 10, 10, 10, 10) // up, down, left, right
|
|
281
|
-
)
|
|
282
|
-
|
|
283
|
-
// multiple regions
|
|
284
|
-
eyes.check(
|
|
285
|
-
Target
|
|
286
|
-
.window()
|
|
287
|
-
.floatingRegions(10, '.floating-area', someElement, someCoordinates) // up, down, left, right all equal to 10
|
|
288
|
-
)
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
Possible input types are:
|
|
292
|
-
|
|
293
|
-
- string (interpreted as css selector)
|
|
294
|
-
- `by` locator
|
|
295
|
-
- element
|
|
296
|
-
- coordinates (`{left, top, width, height}`)
|
|
297
|
-
|
|
298
|
-
##### Content/Strict/Layout Regions
|
|
299
|
-
|
|
300
|
-
<!-- TODO add explanation -->
|
|
301
|
-
|
|
302
|
-
```js
|
|
303
|
-
// viewport screenshot with content region
|
|
304
|
-
eyes.check(Target.window().contentRegion('.some-element'))
|
|
305
|
-
|
|
306
|
-
// viewport screenshot with strict region
|
|
307
|
-
eyes.check(Target.window().strictRegion('.some-element'))
|
|
308
|
-
|
|
309
|
-
// viewport screenshot with layout region
|
|
310
|
-
eyes.check(Target.window().layoutRegion('.some-element'))
|
|
311
|
-
|
|
312
|
-
// multiple regions
|
|
313
|
-
Target.window().contentRegions(region1, region2, region3)
|
|
314
|
-
Target.window().strictRegions(region1, region2, region3)
|
|
315
|
-
Target.window().layoutRegions(region1, region2, region3)
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
Possible input types are:
|
|
319
|
-
|
|
320
|
-
- string (interpreted as css selector)
|
|
321
|
-
- `by` locator
|
|
322
|
-
- element
|
|
323
|
-
- coordinates (`{left, top, width, height}`)
|
|
324
|
-
|
|
325
|
-
##### Accessiblity Regions
|
|
326
|
-
|
|
327
|
-
<!-- TODO add explanation -->
|
|
328
|
-
|
|
329
|
-
```js
|
|
330
|
-
const {AccessibilityRegionType} = require('@applitools/eyes-selenium')
|
|
331
|
-
|
|
332
|
-
// viewport screenshot with accessibility region
|
|
333
|
-
eyes.check(
|
|
334
|
-
Target.window().accessibilityRegion('.some-element', AccessibilityRegionType.LargeText)
|
|
335
|
-
)
|
|
336
|
-
|
|
337
|
-
// multiple regions is done by chaining the same method
|
|
338
|
-
eyes.check(
|
|
339
|
-
Target.window()
|
|
340
|
-
.accessibilityRegion('.element-1', AccessibilityRegionType.LargeText)
|
|
341
|
-
.accessibilityRegion('.element-2', AccessibilityRegionType.IgnoreContrast)
|
|
342
|
-
.accessibilityRegion('.element-3', AccessibilityRegionType.BoldText)
|
|
343
|
-
)
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
Possible input types are:
|
|
347
|
-
|
|
348
|
-
- string (interpreted as css selector)
|
|
349
|
-
- `by` locator
|
|
350
|
-
- element
|
|
351
|
-
- coordinates (`{left, top, width, height}`)
|
|
352
|
-
|
|
353
|
-
##### Scroll root element
|
|
354
|
-
|
|
355
|
-
<!-- TODO add explanation -->
|
|
356
|
-
|
|
357
|
-
```js
|
|
358
|
-
// full page with custom scroll root element
|
|
359
|
-
eyes.check(
|
|
360
|
-
Target.window().fully().scrollRootElement('.main-content')
|
|
361
|
-
)
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
Possible input types are:
|
|
365
|
-
|
|
366
|
-
- string (interpreted as css selector)
|
|
367
|
-
- `by` locator
|
|
368
|
-
- element
|
|
369
|
-
|
|
370
|
-
##### Tag (`withName`)
|
|
371
|
-
|
|
372
|
-
Defines a name for the checkpoint in the Eyes Test Manager. The name may be any string and serves to identify the step to the user in the Test manager. You may change the tag value without impacting testing in any way since Eyes does not use the tag to identify the baseline step that corresponds to the checkpoint - Eyes matches steps based on their content and position in the sequences of images of the test. See [How Eyes compares checkpoints and baseline images](https://applitools.com/docs/topics/general-concepts/how-eyes-compares-checkpoints.html) for details.
|
|
373
|
-
|
|
374
|
-
```js
|
|
375
|
-
eyes.check(Target.window().withName('Main page'))
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
##### Variation group ID
|
|
379
|
-
|
|
380
|
-
```js
|
|
381
|
-
eyes.check(Target.window().variationGroupId('Login button on the right'))
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
_For more information, visit our documentation page: https://applitools.com/docs/features/baseline-variations-groups.html_
|
|
385
|
-
|
|
386
|
-
##### Lazy loading (`lazyLoad`)
|
|
387
|
-
|
|
388
|
-
It's possible to have the SDK scroll the entire page (or a specific length of the page) to make sure all lazyily loaded assets are on the page before performing a check.
|
|
389
|
-
|
|
390
|
-
```js
|
|
391
|
-
// lazy loads with sensible defaults
|
|
392
|
-
eyes.check(Target.window().lazyLoad())
|
|
393
|
-
|
|
394
|
-
// lazy loads with options specified
|
|
395
|
-
eyes.check(Target.window().lazyLoad({
|
|
396
|
-
maxAmountToScroll: 1000, // total pixels of the page to be scrolled
|
|
397
|
-
scrollLength: 250, // amount of pixels to use for each scroll attempt
|
|
398
|
-
waitingTime: 500, // milliseconds to wait in-between each scroll attempt
|
|
399
|
-
}))
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
Possible input types are:
|
|
403
|
-
|
|
404
|
-
- nothing (enables sensible defaults)
|
|
405
|
-
- options object (`{maxAmountToScroll, waitingTime, scrollLength}`)
|
|
406
|
-
|
|
407
|
-
Other details:
|
|
408
|
-
|
|
409
|
-
- If an option is omitted, the sensible default for that value will be used
|
|
410
|
-
- The SDK will repeatedly scroll the page using the `scrollLength` until either the page cannot be scrolled further or the `maxAmountToScroll` has been reached (whichever happens first)
|
|
411
|
-
- If more time is needed for additional content to load, then increase the waitingTime to a value higher than 500 milliseconds. If better performance is desired and additional content lazily loads faster than the default waitingTime, then reduce it to a value below 500 milliseconds
|
|
412
|
-
|
|
413
|
-
##### Density metrics (`densityMetrics`)
|
|
414
|
-
|
|
415
|
-
In order to set the density metrics for the screenshot, use the `densityMetrics` method. This method accepts a object value with the following properties:
|
|
416
|
-
|
|
417
|
-
- `xdpi` - The exact physical pixels per inch of the screen in the X dimension.
|
|
418
|
-
- `ydpi` - The exact physical pixels per inch of the screen in the Y dimension.
|
|
419
|
-
- `scaleRatio` - The scale ratio.
|
|
420
|
-
|
|
421
|
-
```js
|
|
422
|
-
// set density metrics
|
|
423
|
-
eyes.check(Target.window().densityMetrics({
|
|
424
|
-
xdpi: 100,
|
|
425
|
-
ydpi: 100,
|
|
426
|
-
scaleRatio: 1
|
|
427
|
-
}))
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
###### Other checkSettings configuration
|
|
431
|
-
|
|
432
|
-
<!-- TODO add explanation -->
|
|
433
|
-
|
|
434
|
-
- `hideScrollbars`
|
|
435
|
-
- `hideCaret`
|
|
436
|
-
- `ignoreDisplacements`
|
|
437
|
-
- `useDom`
|
|
438
|
-
- `enablePatterns`
|
|
439
|
-
|
|
440
|
-
### close
|
|
441
|
-
|
|
442
|
-
Closes the applitools test and check that all screenshots are valid.
|
|
443
|
-
|
|
444
|
-
It is important to call this at the end of each test, symmetrically to `open`(or in `afterEach()`, see [Best practice for using the SDK](#best-practice-for-using-the-sdk)).
|
|
445
|
-
|
|
446
|
-
```js
|
|
447
|
-
const testResults = await eyes.close(throwEx)
|
|
448
|
-
```
|
|
449
|
-
|
|
450
|
-
- `throwEx` - (Boolean) throw an error if visual differences were found, or if the test failed for any other reason. The deault is `true`.
|
|
451
|
-
|
|
452
|
-
Return value: [`TestResults`](#test-results).
|
|
453
|
-
|
|
454
|
-
## Runners
|
|
455
|
-
|
|
456
|
-
There are two types of runners: `ClassicRunner` and `VisualGridRunner`:
|
|
457
|
-
|
|
458
|
-
1. `ClassicRunner` - used when the screenshot is taken by the SDK itself.
|
|
459
|
-
|
|
460
|
-
```js
|
|
461
|
-
const {ClassicRunner} = require('@applitools/eyes-selenium')
|
|
462
|
-
const runner = new ClassicRunner()
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
2. `VisualGridRunner` - used when the screenshot is taken by the **Ultrafast grid**.
|
|
466
|
-
|
|
467
|
-
```js
|
|
468
|
-
const {VisualGridRunner} = require('@applitools/eyes-selenium')
|
|
469
|
-
const runner = new VisualGridRunner(concurrentSessions)
|
|
470
|
-
```
|
|
471
|
-
|
|
472
|
-
- `concurrentSessions` - (Number) the number of visual tests that are allowed to run at the same time. Default: `1`.
|
|
473
|
-
|
|
474
|
-
### Purpose of runners
|
|
475
|
-
|
|
476
|
-
There are two purposes for using runners:
|
|
477
|
-
|
|
478
|
-
#### 1. Use the Ultrafast grid
|
|
479
|
-
|
|
480
|
-
This is done simply by specifying the `VisualGridRunner`. Browsers are specified by using the [`Configuration`](#configuration) API. For example:
|
|
481
|
-
|
|
482
|
-
```js
|
|
483
|
-
const {Eyes, VisualGridRunner, BrowserType, DeviceName} = require('@applitools/eyes-selenium')
|
|
484
|
-
const eyes = new Eyes(new VisualGridRunner)
|
|
485
|
-
const configuration = eyes.getConfiguration()
|
|
486
|
-
|
|
487
|
-
configuration.addBrowser({width: 1200, height: 800, name: BrowserType.CHROME})
|
|
488
|
-
configuration.addBrowser({width: 1200, height: 800, name: BrowserType.FIREFOX})
|
|
489
|
-
configuration.addBrowser({width: 1200, height: 800, name: BrowserType.SAFARI})
|
|
490
|
-
configuration.addBrowser({width: 1200, height: 800, name: BrowserType.EDGE})
|
|
491
|
-
configuration.addBrowser({width: 1200, height: 800, name: BrowserType.IE_11})
|
|
492
|
-
configuration.addBrowser({deviceName: DeviceName.Galaxy_S9_Plus})
|
|
493
|
-
|
|
494
|
-
eyes.setConfiguration(configuration)
|
|
495
|
-
```
|
|
496
|
-
|
|
497
|
-
#### 2. Manage tests across multiple `Eyes` instances
|
|
498
|
-
|
|
499
|
-
If you decide to create more than one instance of `Eyes` in your tests (for example, if you run `new Eyes()` in `beforeEach` test hooks), the runner provides a method called **`getAllTestResults`** for collecting test results across all eyes instances.
|
|
500
|
-
|
|
501
|
-
Consider the following:
|
|
502
|
-
|
|
503
|
-
```js
|
|
504
|
-
const {Eyes, ClassicRunner, StitchMode} = require('applitools/eyes-selenium')
|
|
505
|
-
const runner = new VisualGridRunner(10)
|
|
506
|
-
|
|
507
|
-
async function runTest(url, ...browsers) {
|
|
508
|
-
await driver.get(url)
|
|
509
|
-
const eyes = new Eyes(runner)
|
|
510
|
-
const configuration = eyes.getConfiguration()
|
|
511
|
-
configuration.addBrowsers(...browsers)
|
|
512
|
-
eyes.setConfiguration(configuration)
|
|
513
|
-
await eyes.open(driver, appName, testName, viewportSize)
|
|
514
|
-
await eyes.check(undefined, Target.window().fully())
|
|
515
|
-
eyes.close()
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
async function collectResults() {
|
|
519
|
-
const testResultsSummary = await runner.getAllTestResults()
|
|
520
|
-
for (const testResultContainer of testResultsSummary) {
|
|
521
|
-
const testResults = testResultContainer.getTestResults()
|
|
522
|
-
console.log(formatTestResults(testResults)) // see the Recipes section below for the implementation of this function
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
Promise.all([
|
|
527
|
-
runTest('https://example.org',
|
|
528
|
-
{width: 1200, height: 800, name: BrowserType.CHROME},
|
|
529
|
-
{width: 1200, height: 800, name: BrowserType.FIREFOX}
|
|
530
|
-
),
|
|
531
|
-
runTest('https://applitools.com',
|
|
532
|
-
{deviceName: DeviceName.Galaxy_S9_Plus},
|
|
533
|
-
{deviceName: DeviceName.iPhone_X}
|
|
534
|
-
)
|
|
535
|
-
]).then(collectResults)
|
|
536
|
-
```
|
|
537
|
-
|
|
538
|
-
This snippet of code runs two visual tests in parallel on two websites, using a specific configuration for each url. To achieve this, multiple `Eyes` instances are used, but in order to wait for all test results, we call `runner.getAllTestResults`. We then iterate through the results and print out a formatted summary.
|
|
539
|
-
|
|
540
|
-
<!-- TODO
|
|
541
|
-
## Configuration
|
|
542
|
-
|
|
543
|
-
show logs
|
|
544
|
-
save debug data ???
|
|
545
|
-
api key
|
|
546
|
-
server url
|
|
547
|
-
proxy
|
|
548
|
-
connection timeout ???
|
|
549
|
-
remove session ???
|
|
550
|
-
ignore baseline
|
|
551
|
-
save new tests
|
|
552
|
-
save failed tests
|
|
553
|
-
match timeout
|
|
554
|
-
match level
|
|
555
|
-
isDisabled
|
|
556
|
-
batch
|
|
557
|
-
properties
|
|
558
|
-
branch name
|
|
559
|
-
parent branch name
|
|
560
|
-
baseline branch name
|
|
561
|
-
environment name
|
|
562
|
-
save diffs
|
|
563
|
-
send dom
|
|
564
|
-
host app
|
|
565
|
-
host os
|
|
566
|
-
host app info
|
|
567
|
-
host os info
|
|
568
|
-
device info
|
|
569
|
-
app name
|
|
570
|
-
test name
|
|
571
|
-
display name
|
|
572
|
-
viewport size
|
|
573
|
-
accessibility validation
|
|
574
|
-
use dom
|
|
575
|
-
enable patterns
|
|
576
|
-
ignore displacements
|
|
577
|
-
ignore caret
|
|
578
|
-
force full page screenshot
|
|
579
|
-
wait before screenshots
|
|
580
|
-
stitch mode
|
|
581
|
-
hide scrollbars
|
|
582
|
-
hide caret
|
|
583
|
-
stitch overlap
|
|
584
|
-
dont close batches
|
|
585
|
-
concurrent sessions ???
|
|
586
|
-
add browsers
|
|
587
|
-
-->
|
|
588
|
-
|
|
589
|
-
## Visual locators
|
|
590
|
-
|
|
591
|
-
Information about what are visual locators and how to use them can be found in the documentation page [here](https://applitools.com/docs/features/visual-locators.html).
|
|
592
|
-
|
|
593
|
-
The API to locate a visual locator in Eyes-Selenium has the following TypeScript signature:
|
|
594
|
-
|
|
595
|
-
```ts
|
|
596
|
-
// Note: This is a formal TypeScript definition.
|
|
597
|
-
// The reason we use the generic type TLocator here is that is shows how the return value of eyes.locate is an object
|
|
598
|
-
// with the same keys as the array of locatorNames in the input to eyes.locate.
|
|
599
|
-
// We explain this in more detail in the example below.
|
|
600
|
-
|
|
601
|
-
interface Eyes {
|
|
602
|
-
locate<TLocator extends string>(settings: VisualLocatorSettings<TLocator>): Promise<Record<TLocator, Array<Region>>>
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
interface VisualLocatorSettings<TLocator extends string> {
|
|
606
|
-
locatorNames: Array<TLocator>;
|
|
607
|
-
firstOnly: boolean;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
interface Region {
|
|
611
|
-
x: number;
|
|
612
|
-
y: number;
|
|
613
|
-
width: number;
|
|
614
|
-
height: number;
|
|
615
|
-
}
|
|
616
|
-
```
|
|
617
|
-
|
|
618
|
-
Here is an example for using this API:
|
|
619
|
-
|
|
620
|
-
```js
|
|
621
|
-
// first need to call eyes.open
|
|
622
|
-
await eyes.open(driver, 'Test app', 'Test visual locators')
|
|
623
|
-
|
|
624
|
-
// example for using eyes.locate
|
|
625
|
-
const regionsMap = await eyes.locate({
|
|
626
|
-
locatorNames: ['locator_a', 'locator_b', 'locator_c'],
|
|
627
|
-
})
|
|
628
|
-
|
|
629
|
-
// now get the coordinates of one of the locators
|
|
630
|
-
const regionsForLocator_A = regionsMap['locator_a']
|
|
631
|
-
|
|
632
|
-
// if region is found, perform press at the middle
|
|
633
|
-
if (regionsForLocator_A && regionsForLocator_A.length > 0) {
|
|
634
|
-
const region = regionsForLocator_A[0]
|
|
635
|
-
const clickLocation = {
|
|
636
|
-
x: region.left + region.width / 2,
|
|
637
|
-
y: region.top + region.height / 2,
|
|
638
|
-
}
|
|
639
|
-
await driver.actions({ bridge: true }).move(clickLocation).click().perform()
|
|
640
|
-
}
|
|
641
|
-
```
|
|
642
|
-
|
|
643
|
-
###
|
|
644
|
-
|
|
645
|
-
## Recipes for common tasks
|
|
646
|
-
|
|
647
|
-
### Configure Server URL
|
|
648
|
-
|
|
649
|
-
By default, Eyes-Selenium communicates with Applitools' public Eyes cloud server, located at `https://eyesapi.applitools.com`.
|
|
650
|
-
|
|
651
|
-
If you have a dedicated cloud or an on-premise server, configure a different Eyes server URL as follows:
|
|
652
|
-
|
|
653
|
-
```js
|
|
654
|
-
eyes.setServerUrl('https://mycompanyeyesapi.applitools.com')
|
|
655
|
-
```
|
|
656
|
-
|
|
657
|
-
### Configure Proxy
|
|
658
|
-
|
|
659
|
-
If your company's network requires requests to go through the corporate proxy, you may configure it as follows:
|
|
660
|
-
|
|
661
|
-
```js
|
|
662
|
-
eyes.setProxy('http://yourproxy.com')
|
|
663
|
-
|
|
664
|
-
// provide username and password:
|
|
665
|
-
eyes.setProxy('http://user:pass@yourproxy.com')
|
|
666
|
-
// OR
|
|
667
|
-
eyes.setProxy({
|
|
668
|
-
url: 'https://yourproxy.com',
|
|
669
|
-
username: 'user',
|
|
670
|
-
password: 'pass'
|
|
671
|
-
})
|
|
672
|
-
|
|
673
|
-
// use tunneling in case of HTTP over HTTPS proxy:
|
|
674
|
-
eyes.setProxy({
|
|
675
|
-
url: 'http://yourproxy.com',
|
|
676
|
-
isHttpOnly: true
|
|
677
|
-
})
|
|
678
|
-
```
|
|
679
|
-
|
|
680
|
-
### Make every visual test correspond to a functional test
|
|
681
|
-
|
|
682
|
-
Every call to `eyes.open` and `eyes.close` defines a test in Applitools Eyes, and all the calls to `eyes.check` between them are called "steps". In order to get a test structure in Applitools that corresponds to the test structure in your functional test, it's best to open/close tests in every `test` call.
|
|
683
|
-
|
|
684
|
-
For example, when running with Mocha as a test runner:
|
|
685
|
-
|
|
686
|
-
```js
|
|
687
|
-
describe('My first visual test', function() {
|
|
688
|
-
beforeEach(async () => {
|
|
689
|
-
await eyes.open(browser, "applitools.com website", "My first Selenium test!")
|
|
690
|
-
})
|
|
691
|
-
afterEach(async () => {
|
|
692
|
-
await eyes.close()
|
|
693
|
-
})
|
|
694
|
-
it('...', async function() {
|
|
695
|
-
// ...
|
|
696
|
-
});
|
|
697
|
-
});
|
|
698
|
-
```
|
|
699
|
-
|
|
700
|
-
### Organize tests in batches
|
|
701
|
-
|
|
702
|
-
It's possible to manage how visual tests are aggregated into batches. Here are two methods for clustering tests into a single batch:
|
|
703
|
-
|
|
704
|
-
#### Method 1: environment variable
|
|
705
|
-
|
|
706
|
-
Run all the processes that execute Selenium with the same value for `APPLITOOLS_BATCH_ID`. For example, run tests with the same randomly generated UUID:
|
|
707
|
-
|
|
708
|
-
```sh
|
|
709
|
-
#! Unix based machines:
|
|
710
|
-
APPLITOOLS_BATCH_ID=`uuidgen` npm test
|
|
711
|
-
|
|
712
|
-
# Powershell on Windows:
|
|
713
|
-
set APPLITOOLS_BATCH_ID = powershell -Command "[guid]::NewGuid().ToString()"
|
|
714
|
-
```
|
|
715
|
-
|
|
716
|
-
It's also possible to control the batch name that shows up in Test Manager. For example:
|
|
717
|
-
|
|
718
|
-
```sh
|
|
719
|
-
export APPLITOOLS_BATCH_ID=`uuidgen`
|
|
720
|
-
export APPLITOOLS_BATCH_NAME="Login tests"
|
|
721
|
-
npm test
|
|
722
|
-
```
|
|
723
|
-
|
|
724
|
-
#### Method 2: `eyes.setBatch`
|
|
725
|
-
|
|
726
|
-
Provide all Eyes instances with the same value for batch ID. For example:
|
|
727
|
-
|
|
728
|
-
```js
|
|
729
|
-
eyes.setBatch({
|
|
730
|
-
id: SOME_SHARED_VALUE_THAT_WILL_BE_THE_SAME_FOR_ALL_TEST_FILES,
|
|
731
|
-
name: 'My batch'
|
|
732
|
-
})
|
|
733
|
-
```
|
|
734
|
-
|
|
735
|
-
### Stitch mode
|
|
736
|
-
|
|
737
|
-
The default stitch mode is `Scroll`. In order to change it:
|
|
738
|
-
|
|
739
|
-
```js
|
|
740
|
-
const {Eyes, StitchMode} = require('@applitools/eyes-selenium')
|
|
741
|
-
|
|
742
|
-
const eyes = new Eyes()
|
|
743
|
-
eyes.setStitchMode(StitchMode.CSS)
|
|
744
|
-
|
|
745
|
-
// to go back to scroll:
|
|
746
|
-
eyes.setStitchMode(StitchMode.SCROLL)
|
|
747
|
-
```
|
|
748
|
-
|
|
749
|
-
#### Background information
|
|
750
|
-
|
|
751
|
-
Eyes-Selenium allows you to control if the checkpoint image should include only the viewport - i.e. what you see in the browser window when you first load a page, or if it should also include the full page - i.e. what you would see if you manually scrolled down, or across, a page that is larger than the viewport.
|
|
752
|
-
|
|
753
|
-
When Eyes-Selenium takes a full page screenshot, it does so by taking multiple screenshots of the viewport at different locations of the page (via the Selenium browser driver), and then "stitching" them together. The output is one clear, potentially very large, screenshot of what can be revealed on the page when it is scrolled.
|
|
754
|
-
|
|
755
|
-
There are two methods for creating the stitched screenshot, and they are both related to the way the page is moved relative to the viewport. Here they are:
|
|
756
|
-
|
|
757
|
-
##### 1. Stitch mode: Scroll
|
|
758
|
-
|
|
759
|
-
Using this method, the page is scrolled, just as a user would scroll. Eyes-Selenium takes the viewport screenshot, then scrolls the page to calculated locations.
|
|
760
|
-
The issue with this method is that the page might respond to scroll events, and change the way it appears visually between the screenshots.
|
|
761
|
-
|
|
762
|
-
##### 2. Stitch mode: CSS
|
|
763
|
-
|
|
764
|
-
Using this method, the page is moved around by changing the CSS property `transform` on the HTML element with different values for `translate(x,y)`.
|
|
765
|
-
This method is not sensitive to scroll events, and is usually the recommended method for stitching.
|
|
766
|
-
|
|
767
|
-
### Stitch overlap
|
|
768
|
-
|
|
769
|
-
The stitch overlap is the length of the intersecting area between two screenshots that are stitched together. It's like placing two printed pictures one on top of the other with some overlapping area between them.
|
|
770
|
-
|
|
771
|
-
This is useful in cases of fixed elements, like a footer, that show up in each of the sub-screenshots. Using a stitch overlap bigger than the size of the footer would make it disappear from every image, and only show up at the bottom of the full page screenshot.
|
|
772
|
-
|
|
773
|
-
The default stitch overlap is 50 pixels. To change it:
|
|
774
|
-
|
|
775
|
-
```js
|
|
776
|
-
eyes.setStitchOverlap(60)
|
|
777
|
-
```
|
|
778
|
-
|
|
779
|
-
### Match level
|
|
780
|
-
|
|
781
|
-
The **match level** determines the way by which Eyes compares the checkpoint image with the baseline image.
|
|
782
|
-
|
|
783
|
-
The default match level is `Strict`. To change it:
|
|
784
|
-
|
|
785
|
-
```js
|
|
786
|
-
// Option 1: For the rest of the execution
|
|
787
|
-
const {MatchLevel} = require('@applitools/eyes-selenium')
|
|
788
|
-
eyes.setMatchLevel(MatchLevel.Layout)
|
|
789
|
-
|
|
790
|
-
// Option 2: For a single checkpoint
|
|
791
|
-
eyes.check(Target.window().layout())
|
|
792
|
-
eyes.check(Target.window().strict())
|
|
793
|
-
eyes.check(Target.window().content())
|
|
794
|
-
eyes.check(Target.window().exact())
|
|
795
|
-
```
|
|
796
|
-
|
|
797
|
-
_For more information, visit our documentation page: https://applitools.com/docs/common/cmn-eyes-match-levels.html_
|
|
798
|
-
|
|
799
|
-
### Ignore displacements
|
|
800
|
-
|
|
801
|
-
By using **ignore displacements** you can hide diffs that arise from content whose position on the page has changed, and focus on mismatches caused by actual changes in the content.
|
|
802
|
-
|
|
803
|
-
The default is `false`. To change it:
|
|
804
|
-
|
|
805
|
-
```js
|
|
806
|
-
// For the rest of the execution
|
|
807
|
-
eyes.setIgnoreDisplacements(true)
|
|
808
|
-
|
|
809
|
-
// For a single checkpoint
|
|
810
|
-
eyes.check(Target.window().ignoreDisplacements())
|
|
811
|
-
```
|
|
812
|
-
|
|
813
|
-
_For more information, visit our documentation page: https://applitools.com/docs/topics/test-manager/viewers/tm-diff-displacement.html_
|
|
814
|
-
|
|
815
|
-
### Test properties
|
|
816
|
-
|
|
817
|
-
It's possible to provide additional information about each test in custom fields, which can then show up in Test Manager in their own column.
|
|
818
|
-
|
|
819
|
-
This is done by calling `setProperties` on the configuration, and providing it with an array of properties with the structure `{name, value}`. For example:
|
|
820
|
-
|
|
821
|
-
```js
|
|
822
|
-
const {Eyes} = require('@applitools/eyes-selenium')
|
|
823
|
-
|
|
824
|
-
const eyes = new Eyes()
|
|
825
|
-
|
|
826
|
-
const configuration = eyes.getConfiguration()
|
|
827
|
-
configuration.setProperties([{name: 'my custom property', value: 'some value'}])
|
|
828
|
-
eyes.setConfiguration(configuration)
|
|
829
|
-
```
|
|
830
|
-
|
|
831
|
-
The test properties could also be specified per batch by calling `setProperties` on the batch info, and providing it with an array of properties with the structure `{name, value}`. For example:
|
|
832
|
-
|
|
833
|
-
```js
|
|
834
|
-
const {Eyes, BatchInfo} = require('@applitools/eyes-selenium')
|
|
835
|
-
|
|
836
|
-
const eyes = new Eyes()
|
|
837
|
-
|
|
838
|
-
const batch = new BatchInfo()
|
|
839
|
-
batch.setProperties([{name: 'my custom batch property', value: 'some value'}])
|
|
840
|
-
|
|
841
|
-
const configuration = eyes.getConfiguration()
|
|
842
|
-
configuration.setBatch(batch)
|
|
843
|
-
eyes.setConfiguration(configuration)
|
|
844
|
-
```
|
|
845
|
-
|
|
846
|
-
### Test results
|
|
847
|
-
|
|
848
|
-
The results of the test can be consumed as the return value from `eyes.close`. Here's an example for creating a formatted output string out of the `TestResults` object:
|
|
849
|
-
|
|
850
|
-
```js
|
|
851
|
-
function formatTestResults(testResults) {
|
|
852
|
-
return `
|
|
853
|
-
Test name : ${testResults.getName()}
|
|
854
|
-
Test status : ${testResults.getStatus()}
|
|
855
|
-
URL to results : ${testResults.getUrl()}
|
|
856
|
-
Total number of steps : ${testResults.getSteps()}
|
|
857
|
-
Number of matching steps : ${testResults.getMatches()}
|
|
858
|
-
Number of visual diffs : ${testResults.getMismatches()}
|
|
859
|
-
Number of missing steps : ${testResults.getMissing()}
|
|
860
|
-
Display size : ${testResults.getHostDisplaySize().toString()}
|
|
861
|
-
Steps :
|
|
862
|
-
${testResults
|
|
863
|
-
.getStepsInfo()
|
|
864
|
-
.map(step => {
|
|
865
|
-
return ` ${step.getName()} - ${getStepStatus(step)}`
|
|
866
|
-
})
|
|
867
|
-
.join('\n')}`
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
function getStepStatus(step) {
|
|
871
|
-
if (step.getIsDifferent()) {
|
|
872
|
-
return 'Diff'
|
|
873
|
-
} else if (!step.getHasBaselineImage()) {
|
|
874
|
-
return 'New'
|
|
875
|
-
} else if (!step.getHasCurrentImage()) {
|
|
876
|
-
return 'Missing'
|
|
877
|
-
} else {
|
|
878
|
-
return 'Passed'
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
```
|
|
882
|
-
|
|
883
|
-
_For the full list of methods, visit our documentation page: https://applitools.com/docs/api/eyes-sdk/index-gen/class-testresults-selenium4-javascript.html_
|
|
884
|
-
|
|
885
|
-
### Logging
|
|
886
|
-
|
|
887
|
-
To enable logging to the console, use the `ConsoleLogHandler` class:
|
|
888
|
-
|
|
889
|
-
```js
|
|
890
|
-
import {Eyes, ConsoleLogHandler} from '@applitools/eyes-selenium'
|
|
891
|
-
|
|
892
|
-
const eyes = new Eyes()
|
|
893
|
-
eyes.setLogHandler(new ConsoleLogHandler())
|
|
894
|
-
|
|
895
|
-
// To enable verbose logging:
|
|
896
|
-
eyes.setLogHandler(new ConsoleLogHandler(true))
|
|
897
|
-
```
|
|
898
|
-
|
|
899
|
-
To write logs to file, use the `FileLogHandler` class. It's possible to configure the file path, verbosity, and whether to append to file.
|
|
900
|
-
|
|
901
|
-
The API is as follows:
|
|
902
|
-
|
|
903
|
-
```js
|
|
904
|
-
new FileLogHandler(isVerbose, filepath, append)
|
|
905
|
-
```
|
|
906
|
-
|
|
907
|
-
Default values are:
|
|
908
|
-
|
|
909
|
-
- `isVerbose`: `false`
|
|
910
|
-
- `filepath`: `'eyes.log'`, meaning a file with this name will be created in the current working directory.
|
|
911
|
-
- `append`: `true`, meaning that every test will append to the file instead of recreating it.
|
|
912
|
-
|
|
913
|
-
For example:
|
|
914
|
-
|
|
915
|
-
```js
|
|
916
|
-
const {Eyes, FileLogHandler} = require('@applitools/eyes-selenium')
|
|
917
|
-
const path = require('path')
|
|
918
|
-
|
|
919
|
-
const eyes = new Eyes()
|
|
920
|
-
|
|
921
|
-
// append non-verbose logs to logs/eyes.log (relative to current working directory)
|
|
922
|
-
eyes.setLogHandler(new FileLogHandler(false, path.resolve('logs', 'eyes.log')))
|
|
923
|
-
|
|
924
|
-
// write verbose logs to a new file at logs/eyes-{timestamp}.log (relative to current working directory)
|
|
925
|
-
eyes.setLogHandler(new FileLogHandler(true, path.resolve('logs', `eyes-${Date.now()}.log`), false))
|
|
926
|
-
```
|
|
927
|
-
|
|
928
|
-
### Configuring browsers for the Ultrafast grid
|
|
929
|
-
|
|
930
|
-
When it comes to multiple browsers and mobile devices, the Ultrafast grid shines.
|
|
931
|
-
It's now possible to run one functional test, and in the background have multiple screenshots rendered for different browsers, viewport sizes, and mobile devices.
|
|
932
|
-
|
|
933
|
-
The API methods are:
|
|
934
|
-
|
|
935
|
-
- `configuration.addBrowser(browser)` for adding a single browser configuration.
|
|
936
|
-
- `configuration.addBrowsers(browser1, browser2, ...)` for adding single or multiple browser configurations.
|
|
937
|
-
|
|
938
|
-
Here are examples for how to execute visual tests on different browsers and platforms:
|
|
939
|
-
|
|
940
|
-
#### Desktop browsers
|
|
941
|
-
|
|
942
|
-
```js
|
|
943
|
-
const {BrowserType} = require('@applitools/eyes-selenium')
|
|
944
|
-
// ...
|
|
945
|
-
const configuration = eyes.getConfiguration()
|
|
946
|
-
configuration.addBrowsers(
|
|
947
|
-
{name: BrowserType.EDGE_CHROMIUM, width: 768, height: 1024},
|
|
948
|
-
{name: BrowserType.EDGE_LEGACY, width: 768, height: 1024},
|
|
949
|
-
{name: BrowserType.FIREFOX, width: 768, height: 1024},
|
|
950
|
-
{name: BrowserType.CHROME, width: 768, height: 1024},
|
|
951
|
-
{name: BrowserType.IE_11, width: 768, height: 1024},
|
|
952
|
-
{name: BrowserType.IE_10, width: 768, height: 1024},
|
|
953
|
-
{name: BrowserType.SAFARI, width: 768, height: 1024},
|
|
954
|
-
{name: BrowserType.CHROME_ONE_VERSION_BACK, width: 768, height: 1024},
|
|
955
|
-
{name: BrowserType.CHROME_TWO_VERSIONS_BACK, width: 768, height: 1024},
|
|
956
|
-
// ...
|
|
957
|
-
)
|
|
958
|
-
eyes.setConfiguration(configuration)
|
|
959
|
-
```
|
|
960
|
-
|
|
961
|
-
#### Chrome device emulation
|
|
962
|
-
|
|
963
|
-
Predefined device:
|
|
964
|
-
|
|
965
|
-
```js
|
|
966
|
-
const {ScreenOrientation, DeviceName} = require('@applitools/eyes-selenium')
|
|
967
|
-
// ...
|
|
968
|
-
const configuration = eyes.getConfiguration()
|
|
969
|
-
configuration.addBrowsers(
|
|
970
|
-
{
|
|
971
|
-
chromeEmulationInfo: {
|
|
972
|
-
deviceName: DeviceName.iPhone_6_7_8,
|
|
973
|
-
},
|
|
974
|
-
},
|
|
975
|
-
{
|
|
976
|
-
chromeEmulationInfo: {
|
|
977
|
-
deviceName: DeviceName.Galaxy_S9_Plus,
|
|
978
|
-
screenOrientation: ScreenOrientation.LANDSCAPE,
|
|
979
|
-
},
|
|
980
|
-
},
|
|
981
|
-
)
|
|
982
|
-
eyes.setConfiguration(configuration)
|
|
983
|
-
```
|
|
984
|
-
|
|
985
|
-
Custom device:
|
|
986
|
-
|
|
987
|
-
```js
|
|
988
|
-
const configuration = eyes.getConfiguration()
|
|
989
|
-
configuration.addBrowser({
|
|
990
|
-
chromeEmulationInfo: {
|
|
991
|
-
width: 800,
|
|
992
|
-
height: 600,
|
|
993
|
-
deviceScaleFactor: 3,
|
|
994
|
-
},
|
|
995
|
-
})
|
|
996
|
-
eyes.setConfiguration(configuration)
|
|
997
|
-
```
|
|
998
|
-
|
|
999
|
-
#### iOS device
|
|
1000
|
-
|
|
1001
|
-
```js
|
|
1002
|
-
const {IosDeviceName, ScreenOrientation, IosVersion} = require('@applitools/eyes-selenium')
|
|
1003
|
-
// ...
|
|
1004
|
-
const configuration = eyes.getConfiguration()
|
|
1005
|
-
configuration.addBrowser({
|
|
1006
|
-
iosDeviceInfo: {
|
|
1007
|
-
deviceName: IosDeviceName.iPhone_11,
|
|
1008
|
-
screenOrientation: ScreenOrientation.LANDSCAPE, // optional, default: ScreenOrientation.PORTRAIT
|
|
1009
|
-
iosVersion: IosVersion.LATEST // optional, default: undefined (i.e. the default is determined by the Ultrafast grid)
|
|
1010
|
-
},
|
|
1011
|
-
})
|
|
1012
|
-
eyes.setConfiguration(configuration)
|
|
1013
|
-
```
|
|
1014
|
-
|
|
1015
|
-
The list of devices is available at https://github.com/applitools/eyes.sdk.javascript1/blob/master/packages/eyes-api/src/enums/IosDeviceName.ts
|
|
1016
|
-
|
|
1017
|
-
Possible values for `iosVersion` are:
|
|
1018
|
-
|
|
1019
|
-
- `IosVersion.LATEST` - the latest iOS version that's supported by the UFG
|
|
1020
|
-
- `IosVersion.LATEST_ONE_VERSION_BACK'` - one version prior to the latest version
|
|
1021
|
-
- `undefined` - the UFG's default
|
|
10
|
+
## Resources
|
|
11
|
+
- [Quick start](https://applitools.com/tutorials/quickstart/web/selenium/javascript)
|
|
12
|
+
- [API reference](https://applitools.com/docs/api-ref/sdk-api/selenium/javascript/)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/eyes-selenium",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.68.1",
|
|
4
4
|
"description": "Applitools Eyes SDK for Selenium WebDriver",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eyes-selenium",
|
|
@@ -17,15 +17,7 @@
|
|
|
17
17
|
"webdriver",
|
|
18
18
|
"webdriverjs"
|
|
19
19
|
],
|
|
20
|
-
"homepage": "https://applitools.com",
|
|
21
|
-
"bugs": {
|
|
22
|
-
"url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
|
|
23
|
-
},
|
|
24
|
-
"repository": {
|
|
25
|
-
"type": "git",
|
|
26
|
-
"url": "git://github.com/applitools/eyes.sdk.javascript1.git",
|
|
27
|
-
"directory": "js/packages/eyes-selenium"
|
|
28
|
-
},
|
|
20
|
+
"homepage": "https://applitools.com/docs/api-ref/sdk-api/selenium/javascript/",
|
|
29
21
|
"license": "SEE LICENSE IN LICENSE",
|
|
30
22
|
"author": {
|
|
31
23
|
"name": "Applitools Team",
|
|
@@ -49,7 +41,7 @@
|
|
|
49
41
|
"up:framework": "yarn add --dev --caret selenium-webdriver${APPLITOOLS_FRAMEWORK_VERSION:+@$APPLITOOLS_FRAMEWORK_VERSION}"
|
|
50
42
|
},
|
|
51
43
|
"dependencies": {
|
|
52
|
-
"@applitools/eyes": "1.8.
|
|
44
|
+
"@applitools/eyes": "1.8.4",
|
|
53
45
|
"@applitools/spec-driver-selenium": "1.5.58"
|
|
54
46
|
},
|
|
55
47
|
"devDependencies": {
|