@applitools/visual-grid-cli-utils 1.21.23 → 1.21.27
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/package.json +2 -1
- package/src/commons/parse-browser.js +1 -1
- package/src/compare.js +50 -0
- package/src/rerender.js +1 -1
- package/src/visual-grid-cli-utils.js +188 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/visual-grid-cli-utils",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.27",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/visual-grid-cli-utils.js",
|
|
6
6
|
"engines": {
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@applitools/dom-snapshot": "^4.5.7",
|
|
40
|
+
"@applitools/eyes-images": "^4.21.0",
|
|
40
41
|
"@applitools/functional-commons": "^1.6.0",
|
|
41
42
|
"@applitools/http-commons": "^2.4.3",
|
|
42
43
|
"@applitools/screenshot-stitching-client": "^8.0.15",
|
|
@@ -3,7 +3,7 @@ const {filterValues} = require('@applitools/functional-commons')
|
|
|
3
3
|
|
|
4
4
|
function parseBrowser(arg) {
|
|
5
5
|
const match =
|
|
6
|
-
/^(chrome|chrome-1|chrome-2|chrome-canary|edgechromium-canary|firefox|firefox-1|firefox-2|firefox-canary|ie11|ie10|edge|safari|safari-1|safari-2|safari-canary|safari-earlyaccess|ie-vmware|edgechromium|edgechromium-1|edgechromium-2|edgechromium-canary|edgelegacy)(\( *(\d+) *(x|,) *(\d+) *\))?$/.exec(
|
|
6
|
+
/^(chrome|chrome-1|chrome-2|chrome-canary|edgechromium-poc-canary|edgechromium-canary|firefox|firefox-1|firefox-2|firefox-canary|ie11|ie10|edge|safari|safari-1|safari-2|safari-canary|safari-earlyaccess|ie-vmware|edgechromium|edgechromium-1|edgechromium-2|edgechromium-canary|edgelegacy)(\( *(\d+) *(x|,) *(\d+) *\))?$/.exec(
|
|
7
7
|
arg,
|
|
8
8
|
)
|
|
9
9
|
|
package/src/compare.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const {Eyes, Target, Configuration, BatchInfo} = require('@applitools/eyes-images')
|
|
3
|
+
const rerender = require('./rerender')
|
|
4
|
+
const {randomUUID} = require('crypto')
|
|
5
|
+
|
|
6
|
+
async function main(args) {
|
|
7
|
+
async function runRerender(browser) {
|
|
8
|
+
const {finalOutputFile} = await rerender({...args, browser})
|
|
9
|
+
return {browser, image: finalOutputFile}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const results = await Promise.all([
|
|
13
|
+
runRerender(args.browser1.browser),
|
|
14
|
+
runRerender(args.browser2.browser),
|
|
15
|
+
])
|
|
16
|
+
await compareWithEyes(results)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function compareWithEyes(rerenderResults) {
|
|
20
|
+
const eyes = new Eyes()
|
|
21
|
+
let batchUrl
|
|
22
|
+
try {
|
|
23
|
+
// Initialize the eyes configuration
|
|
24
|
+
const configuration = new Configuration()
|
|
25
|
+
|
|
26
|
+
// Set new batch
|
|
27
|
+
configuration.setBatch(new BatchInfo('VG-CLI compare'))
|
|
28
|
+
|
|
29
|
+
// Set the configuration to eyes
|
|
30
|
+
eyes.setConfiguration(configuration)
|
|
31
|
+
|
|
32
|
+
const uuid = randomUUID()
|
|
33
|
+
let i = 0
|
|
34
|
+
for (const result of rerenderResults) {
|
|
35
|
+
await eyes.open('VG-CLI compare', `Compare browsers ${uuid}`)
|
|
36
|
+
const {browser: name, image: file} = result
|
|
37
|
+
const resp = await eyes.check(name, Target.image(file))
|
|
38
|
+
batchUrl = batchUrl || eyes.getRunningSession().getUrl()
|
|
39
|
+
console.log(`${++i}. ${name} check result: ${resp}`)
|
|
40
|
+
await eyes.close()
|
|
41
|
+
}
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.error(err)
|
|
44
|
+
} finally {
|
|
45
|
+
await eyes.abortIfNotClosed()
|
|
46
|
+
console.log('\nBatch results: \n', batchUrl)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = main
|
package/src/rerender.js
CHANGED
|
@@ -241,6 +241,194 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
241
241
|
type: 'string',
|
|
242
242
|
}),
|
|
243
243
|
)
|
|
244
|
+
.command(
|
|
245
|
+
'compare <renderId> <browser1> <browser2>',
|
|
246
|
+
'rerender a previous render to png',
|
|
247
|
+
(yargs) =>
|
|
248
|
+
yargs
|
|
249
|
+
.option('api-key', {
|
|
250
|
+
alias: 'k',
|
|
251
|
+
describe:
|
|
252
|
+
"alternative api key (an execute key, and if it's not a read key, comma then a read key)",
|
|
253
|
+
default: process.env.APPLITOOLS_API_KEY,
|
|
254
|
+
defaultDescription: 'APPLITOOLS_API_KEY env var',
|
|
255
|
+
type: 'string',
|
|
256
|
+
})
|
|
257
|
+
.option('server-url', {
|
|
258
|
+
describe: 'alternative Eyes server url',
|
|
259
|
+
default: process.env.APPLITOOLS_SERVER_URL || 'https://eyesapi.applitools.com',
|
|
260
|
+
defaultDescription: 'APPLITOOLS_SERVER_URL env var or default eyes server',
|
|
261
|
+
type: 'string',
|
|
262
|
+
})
|
|
263
|
+
.option('auth-token', {
|
|
264
|
+
describe: 'alternative authToken (for testing purposes only)',
|
|
265
|
+
type: 'string',
|
|
266
|
+
})
|
|
267
|
+
.option('account-override', {
|
|
268
|
+
alias: 'o',
|
|
269
|
+
describe: 'account that rendered (works for Visual Grid super-admins only!)',
|
|
270
|
+
default: process.env.ACCOUNT_OVERRIDE,
|
|
271
|
+
type: 'string',
|
|
272
|
+
})
|
|
273
|
+
.option('output', {
|
|
274
|
+
describe: 'wether to write results to disk or not',
|
|
275
|
+
type: 'boolean',
|
|
276
|
+
default: true,
|
|
277
|
+
})
|
|
278
|
+
.option('output-file', {
|
|
279
|
+
describe: 'to which file to write the result',
|
|
280
|
+
type: 'string',
|
|
281
|
+
defaultDescription: 'a random file in the tmp directory',
|
|
282
|
+
})
|
|
283
|
+
.positional('browser1', {
|
|
284
|
+
alias: 'b1',
|
|
285
|
+
demandOption: true,
|
|
286
|
+
describe: 'browser A',
|
|
287
|
+
type: 'string',
|
|
288
|
+
coerce: parseBrowser,
|
|
289
|
+
default: 'chrome',
|
|
290
|
+
})
|
|
291
|
+
.positional('browser2', {
|
|
292
|
+
alias: 'b2',
|
|
293
|
+
demandOption: true,
|
|
294
|
+
describe: 'browser B',
|
|
295
|
+
type: 'string',
|
|
296
|
+
coerce: parseBrowser,
|
|
297
|
+
default: 'edgechromium',
|
|
298
|
+
})
|
|
299
|
+
.option('headless', {
|
|
300
|
+
describe: 'render on headless chrome (use false for beta headful)',
|
|
301
|
+
default: true,
|
|
302
|
+
type: 'boolean',
|
|
303
|
+
})
|
|
304
|
+
.option('canary', {
|
|
305
|
+
describe: 'send the rendering to the canary browser (for internal purposes)',
|
|
306
|
+
default: false,
|
|
307
|
+
type: 'boolean',
|
|
308
|
+
})
|
|
309
|
+
.option('device-emulation', {
|
|
310
|
+
describe: 'the device name to use for chrome emulation',
|
|
311
|
+
type: 'string',
|
|
312
|
+
})
|
|
313
|
+
.option('device-orientation', {
|
|
314
|
+
describe: 'portrait or landscape',
|
|
315
|
+
type: 'string',
|
|
316
|
+
choices: ['portrait', 'landscape'],
|
|
317
|
+
default: 'portrait',
|
|
318
|
+
})
|
|
319
|
+
.option('android-device-name', {
|
|
320
|
+
describe: 'the name of the Android device to use',
|
|
321
|
+
type: 'string',
|
|
322
|
+
})
|
|
323
|
+
.option('android-version', {
|
|
324
|
+
describe:
|
|
325
|
+
'The Android version to use (latest, latest-1 or latest-2 - relative to the device)',
|
|
326
|
+
type: 'string',
|
|
327
|
+
default: 'latest',
|
|
328
|
+
})
|
|
329
|
+
.option('android-device-orientation', {
|
|
330
|
+
describe: 'screen orientation',
|
|
331
|
+
type: 'string',
|
|
332
|
+
choices: ['portrait', 'landscape'],
|
|
333
|
+
default: 'portrait',
|
|
334
|
+
})
|
|
335
|
+
.option('android-vhs-type', {
|
|
336
|
+
describe: 'vhs type',
|
|
337
|
+
type: 'string',
|
|
338
|
+
choices: ['android-x', 'android-support'],
|
|
339
|
+
default: 'android-x',
|
|
340
|
+
})
|
|
341
|
+
.option('ios-device-name', {
|
|
342
|
+
describe: 'the name of the iOS device to use',
|
|
343
|
+
type: 'string',
|
|
344
|
+
})
|
|
345
|
+
.option('ios-version', {
|
|
346
|
+
describe: 'The iOS version to use (none, latest, latest-1, etc)',
|
|
347
|
+
type: 'string',
|
|
348
|
+
})
|
|
349
|
+
.option('ios-device-orientation', {
|
|
350
|
+
describe: 'screen orientation',
|
|
351
|
+
type: 'string',
|
|
352
|
+
choices: ['portrait', 'landscapeLeft', 'landscapeRight'],
|
|
353
|
+
default: 'portrait',
|
|
354
|
+
})
|
|
355
|
+
.option('target', {
|
|
356
|
+
describe: 'what to render',
|
|
357
|
+
type: 'string',
|
|
358
|
+
choices: ['viewport', 'full-page', 'selector', 'full-selector'],
|
|
359
|
+
default: 'full-page',
|
|
360
|
+
})
|
|
361
|
+
.option('vhs-compatibility-params', {
|
|
362
|
+
describe:
|
|
363
|
+
'should specify vhs compatibility params if running ios native jobs. Specify the value of UIKitLinkTimeVersionNumber followed by the value of UIKitRunTimeVersionNumber - e.g. --vhs-compatibility-params 4555 5067',
|
|
364
|
+
type: 'array',
|
|
365
|
+
})
|
|
366
|
+
.option('selector', {
|
|
367
|
+
describe: 'target a specific element (via CSS selector)',
|
|
368
|
+
type: 'string',
|
|
369
|
+
})
|
|
370
|
+
.option('chained-selectors', {
|
|
371
|
+
describe:
|
|
372
|
+
'target an element inside a shadow-root or an iframe. Specify selectors in the following format: --chained-selectors "<selector1>" "<nodeType(iframe | shadow-root | element)>" "<selector2>" "<nodeType>"',
|
|
373
|
+
type: 'array',
|
|
374
|
+
})
|
|
375
|
+
.option('selectors-to-find-regions-for', {
|
|
376
|
+
describe:
|
|
377
|
+
'selectors to find regions for - Specify selectors in the following format: "<selector1>" "xpath || css" <selector2>" "xpath || css"...',
|
|
378
|
+
type: 'array',
|
|
379
|
+
})
|
|
380
|
+
.option('region', {
|
|
381
|
+
describe: 'target a specific region',
|
|
382
|
+
type: 'string',
|
|
383
|
+
coerce: parseRegion,
|
|
384
|
+
})
|
|
385
|
+
.option('width', {
|
|
386
|
+
describe: 'width of viewport',
|
|
387
|
+
type: 'number',
|
|
388
|
+
default: 1024,
|
|
389
|
+
})
|
|
390
|
+
.option('height', {
|
|
391
|
+
describe: 'height of viewport',
|
|
392
|
+
type: 'number',
|
|
393
|
+
default: 768,
|
|
394
|
+
})
|
|
395
|
+
.option('bcs-hook', {
|
|
396
|
+
describe: 'beforeCaptureScreenshot hook',
|
|
397
|
+
type: 'string',
|
|
398
|
+
})
|
|
399
|
+
.option('rca', {
|
|
400
|
+
describe: 'enable Root Cause Analysis',
|
|
401
|
+
type: 'boolean',
|
|
402
|
+
default: false,
|
|
403
|
+
})
|
|
404
|
+
.option('native', {
|
|
405
|
+
describe: 'Use native renderer',
|
|
406
|
+
type: 'boolean',
|
|
407
|
+
default: false,
|
|
408
|
+
})
|
|
409
|
+
.option('view-rendering', {
|
|
410
|
+
alias: 'v',
|
|
411
|
+
describe: 'also output the view-rendering url',
|
|
412
|
+
type: 'boolean',
|
|
413
|
+
default: false,
|
|
414
|
+
})
|
|
415
|
+
.option('includeFullPageSize', {
|
|
416
|
+
alias: 'f',
|
|
417
|
+
describe: 'output the full page size after rendering',
|
|
418
|
+
type: 'boolean',
|
|
419
|
+
default: false,
|
|
420
|
+
})
|
|
421
|
+
.option('timeout', {
|
|
422
|
+
alias: 't',
|
|
423
|
+
describe: 'Timeout for operation (ms)',
|
|
424
|
+
default: 60000,
|
|
425
|
+
type: 'number',
|
|
426
|
+
})
|
|
427
|
+
.option('options', {
|
|
428
|
+
describe: 'send visual grid options to rendering (json)',
|
|
429
|
+
type: 'string',
|
|
430
|
+
}),
|
|
431
|
+
)
|
|
244
432
|
.command('job-info', 'get the job info for a rendering job', (yargs) =>
|
|
245
433
|
yargs
|
|
246
434
|
.option('api-key', {
|