@applitools/eyes-puppeteer 1.18.4 → 1.19.0

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