@applitools/visual-grid-cli-utils 1.21.21 → 1.21.25
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 +4 -1
- package/src/commons/parse-browser.js +1 -1
- package/src/commons/wait-for-rendering.js +3 -2
- package/src/compare.js +50 -0
- package/src/rerender.js +12 -3
- package/src/visual-grid-cli-utils.js +194 -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.25",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/visual-grid-cli-utils.js",
|
|
6
6
|
"engines": {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"vg-cli": "scripts/run-visual-grid-cli-utils.js"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
|
+
"distribute": "pkg scripts/run-visual-grid-cli-utils.js --out-path dist",
|
|
20
21
|
"start": "scripts/run-visual-grid-cli-utils.js",
|
|
21
22
|
"test:mocha": "mocha --no-timeouts --exit 'test/unit/*.test.js' 'test/it/*.test.js' 'test/e2e/*.test.js'",
|
|
22
23
|
"test": "npm run eslint && npm run test:mocha",
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
39
|
"@applitools/dom-snapshot": "^4.5.7",
|
|
40
|
+
"@applitools/eyes-images": "^4.21.0",
|
|
39
41
|
"@applitools/functional-commons": "^1.6.0",
|
|
40
42
|
"@applitools/http-commons": "^2.4.3",
|
|
41
43
|
"@applitools/screenshot-stitching-client": "^8.0.15",
|
|
@@ -62,6 +64,7 @@
|
|
|
62
64
|
"eslint-plugin-node": "^11.1.0",
|
|
63
65
|
"eslint-plugin-prettier": "^3.4.1",
|
|
64
66
|
"mocha": "^8.3.2",
|
|
67
|
+
"pkg": "^5.5.2",
|
|
65
68
|
"prettier": "^2.2.1"
|
|
66
69
|
}
|
|
67
70
|
}
|
|
@@ -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
|
|
|
@@ -12,13 +12,14 @@ async function waitForRendering(vgUrl, renderId, authToken, waitTimeout = 10 * 6
|
|
|
12
12
|
`failed to get rendering status. Error from Visual Grid: ${await response.text()}`,
|
|
13
13
|
)
|
|
14
14
|
}
|
|
15
|
-
const {status, error, imageLocation, domLocation, selectorRegions} =
|
|
15
|
+
const {status, error, imageLocation, domLocation, selectorRegions, fullPageSize} =
|
|
16
|
+
await response.json()
|
|
16
17
|
if (status === 'error') {
|
|
17
18
|
return [error]
|
|
18
19
|
} else if (status === 'rendering') {
|
|
19
20
|
throw new Error(``)
|
|
20
21
|
} else {
|
|
21
|
-
return [undefined, imageLocation, domLocation, selectorRegions]
|
|
22
|
+
return [undefined, imageLocation, domLocation, selectorRegions, fullPageSize]
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
25
|
{
|
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
|
+
try {
|
|
22
|
+
// Initialize the eyes configuration
|
|
23
|
+
const configuration = new Configuration()
|
|
24
|
+
|
|
25
|
+
// Set new batch
|
|
26
|
+
configuration.setBatch(new BatchInfo('VG-CLI compare'))
|
|
27
|
+
|
|
28
|
+
// Set the configuration to eyes
|
|
29
|
+
eyes.setConfiguration(configuration)
|
|
30
|
+
|
|
31
|
+
const uuid = randomUUID()
|
|
32
|
+
|
|
33
|
+
let i = 0
|
|
34
|
+
for (const result of rerenderResults) {
|
|
35
|
+
const {browser: name, image: file} = result
|
|
36
|
+
|
|
37
|
+
await eyes.open('VG-CLI compare', `Compare browsers ${uuid}`, {width: 800, height: 600})
|
|
38
|
+
const resp = await eyes.check(name, Target.image(file))
|
|
39
|
+
console.log(`${name} resp ${i} = ${resp}`)
|
|
40
|
+
if (++i === rerenderResults.length - 1) {
|
|
41
|
+
console.log('\nBatch results: \n', eyes.getRunningSession().getUrl())
|
|
42
|
+
}
|
|
43
|
+
await eyes.close()
|
|
44
|
+
}
|
|
45
|
+
} finally {
|
|
46
|
+
await eyes.abortIfNotClosed()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = main
|
package/src/rerender.js
CHANGED
|
@@ -40,6 +40,7 @@ async function main({
|
|
|
40
40
|
rca,
|
|
41
41
|
native,
|
|
42
42
|
viewRendering,
|
|
43
|
+
includeFullPageSize,
|
|
43
44
|
canary,
|
|
44
45
|
iosVersion,
|
|
45
46
|
timeout,
|
|
@@ -85,7 +86,7 @@ async function main({
|
|
|
85
86
|
? {
|
|
86
87
|
name: androidDeviceName,
|
|
87
88
|
screenOrientation: androidDeviceOrientation,
|
|
88
|
-
version: androidVersion,
|
|
89
|
+
version: canary ? 'canary' : androidVersion,
|
|
89
90
|
}
|
|
90
91
|
: undefined,
|
|
91
92
|
vhsType: androidDeviceName ? androidVhsType : undefined,
|
|
@@ -103,6 +104,7 @@ async function main({
|
|
|
103
104
|
? normalizeSelectorsToFindRegionsForArray(selectorsToFindRegionsFor)
|
|
104
105
|
: undefined,
|
|
105
106
|
enableMultipleResultsPerSelector: true,
|
|
107
|
+
includeFullPageSize,
|
|
106
108
|
sendDom: rca,
|
|
107
109
|
agentId: `visual-grid-cli-utils/${require('../package.json').version}`,
|
|
108
110
|
// browser: {
|
|
@@ -128,7 +130,7 @@ async function main({
|
|
|
128
130
|
|
|
129
131
|
const {renderId: reRenderId} = await response.json()
|
|
130
132
|
|
|
131
|
-
const [err, imageLocation, domLocation, selectorRegions] = await waitForRendering(
|
|
133
|
+
const [err, imageLocation, domLocation, selectorRegions, fullPageSize] = await waitForRendering(
|
|
132
134
|
vgUrl,
|
|
133
135
|
reRenderId,
|
|
134
136
|
authToken,
|
|
@@ -180,7 +182,14 @@ async function main({
|
|
|
180
182
|
console.log('\n' + calculateViewRenderingUrl(renderId, authToken))
|
|
181
183
|
}
|
|
182
184
|
|
|
183
|
-
|
|
185
|
+
if (includeFullPageSize) {
|
|
186
|
+
console.log('-----')
|
|
187
|
+
console.log(`Full page size:`)
|
|
188
|
+
console.log(JSON.stringify(fullPageSize, null, 2))
|
|
189
|
+
console.log('-----')
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return {finalOutputFile, reRenderId}
|
|
184
193
|
}
|
|
185
194
|
|
|
186
195
|
function normalizeSelectorsToFindRegionsForArray(selectorsToFindRegionsFor) {
|
|
@@ -224,6 +224,12 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
224
224
|
type: 'boolean',
|
|
225
225
|
default: false,
|
|
226
226
|
})
|
|
227
|
+
.option('includeFullPageSize', {
|
|
228
|
+
alias: 'f',
|
|
229
|
+
describe: 'output the full page size after rendering',
|
|
230
|
+
type: 'boolean',
|
|
231
|
+
default: false,
|
|
232
|
+
})
|
|
227
233
|
.option('timeout', {
|
|
228
234
|
alias: 't',
|
|
229
235
|
describe: 'Timeout for operation (ms)',
|
|
@@ -235,6 +241,194 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
235
241
|
type: 'string',
|
|
236
242
|
}),
|
|
237
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
|
+
)
|
|
238
432
|
.command('job-info', 'get the job info for a rendering job', (yargs) =>
|
|
239
433
|
yargs
|
|
240
434
|
.option('api-key', {
|