@applitools/visual-grid-cli-utils 1.21.16 → 1.21.20
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
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
function normalizeChainedSelectorsArray(chainedSelectors) {
|
|
3
|
+
const cs = []
|
|
4
|
+
for (let i = 0; i < chainedSelectors.length; i += 2) {
|
|
5
|
+
cs.push({
|
|
6
|
+
selector: chainedSelectors[i],
|
|
7
|
+
type: chainedSelectors[i].startsWith('//') ? 'xpath' : 'css',
|
|
8
|
+
nodeType: i + 1 < chainedSelectors.length ? chainedSelectors[i + 1] : 'element',
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return cs
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = normalizeChainedSelectorsArray
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const retry = require('p-retry')
|
|
2
2
|
const {fetch} = require('@applitools/http-commons')
|
|
3
3
|
|
|
4
|
-
async function waitForRendering(vgUrl, renderId, authToken) {
|
|
4
|
+
async function waitForRendering(vgUrl, renderId, authToken, waitTimeout = 10 * 60 * 1000) {
|
|
5
5
|
return await retry(
|
|
6
6
|
async () => {
|
|
7
7
|
const response = await fetch(`${vgUrl}/render-status?render-id=${renderId}`, {
|
|
@@ -25,7 +25,7 @@ async function waitForRendering(vgUrl, renderId, authToken) {
|
|
|
25
25
|
forever: true,
|
|
26
26
|
minTimeout: 1000,
|
|
27
27
|
maxTimeout: 1000,
|
|
28
|
-
maxRetryTime:
|
|
28
|
+
maxRetryTime: waitTimeout,
|
|
29
29
|
onFailedAttempt: (err) => (err.message ? console.log(err.message) : undefined),
|
|
30
30
|
},
|
|
31
31
|
)
|
package/src/rerender.js
CHANGED
|
@@ -10,6 +10,7 @@ const {writeImageLocationToFile, writeDomLocationToFile} = require('./write-imag
|
|
|
10
10
|
const {plotDomCaptureToHtml} = require('./plot-dom-capture-to-html')
|
|
11
11
|
const {convertBrowserNameToCanary} = require('./commons/parse-browser')
|
|
12
12
|
const parseJson = require('./commons/parse-json.js')
|
|
13
|
+
const normalizeChainedSelectorsArray = require('./commons/normalizeChainedSelectorsArray')
|
|
13
14
|
|
|
14
15
|
async function main({
|
|
15
16
|
apiKey,
|
|
@@ -41,7 +42,9 @@ async function main({
|
|
|
41
42
|
viewRendering,
|
|
42
43
|
canary,
|
|
43
44
|
iosVersion,
|
|
45
|
+
timeout,
|
|
44
46
|
options: optionsAsString,
|
|
47
|
+
selectorsToFindRegionsFor,
|
|
45
48
|
}) {
|
|
46
49
|
const options = parseJson(optionsAsString, 'options')
|
|
47
50
|
options.chromeHeadless = headless
|
|
@@ -89,7 +92,9 @@ async function main({
|
|
|
89
92
|
: undefined,
|
|
90
93
|
region: region,
|
|
91
94
|
},
|
|
92
|
-
selectorsToFindRegionsFor:
|
|
95
|
+
selectorsToFindRegionsFor: selectorsToFindRegionsFor
|
|
96
|
+
? normalizeSelectorsToFindRegionsForArray(selectorsToFindRegionsFor)
|
|
97
|
+
: undefined,
|
|
93
98
|
enableMultipleResultsPerSelector: true,
|
|
94
99
|
sendDom: rca,
|
|
95
100
|
agentId: `visual-grid-cli-utils/${require('../package.json').version}`,
|
|
@@ -120,6 +125,7 @@ async function main({
|
|
|
120
125
|
vgUrl,
|
|
121
126
|
reRenderId,
|
|
122
127
|
authToken,
|
|
128
|
+
timeout,
|
|
123
129
|
)
|
|
124
130
|
|
|
125
131
|
if (err) {
|
|
@@ -151,17 +157,16 @@ async function main({
|
|
|
151
157
|
outputFile: domSnapshotHtml,
|
|
152
158
|
})
|
|
153
159
|
|
|
154
|
-
console.log(
|
|
155
|
-
`\n${domSnapshotOutputFile}: dom capture json${
|
|
156
|
-
selectorRegions && selectorRegions.length > 0 && selectorRegions[0].length > 0
|
|
157
|
-
? `, at offset ${selectorRegions[0][0].x},${selectorRegions[0][0].y}`
|
|
158
|
-
: ''
|
|
159
|
-
}`,
|
|
160
|
-
)
|
|
160
|
+
console.log(`\n${domSnapshotOutputFile}: dom capture json`)
|
|
161
161
|
console.log(domSnapshotHtml + ': dom capture rectangles')
|
|
162
162
|
}
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
|
|
164
|
+
if (selectorRegions) {
|
|
165
|
+
console.log('-----')
|
|
166
|
+
console.log(`selector regions output:`)
|
|
167
|
+
console.log(JSON.stringify(selectorRegions, null, 2))
|
|
168
|
+
console.log('-----')
|
|
169
|
+
}
|
|
165
170
|
}
|
|
166
171
|
|
|
167
172
|
if (viewRendering) {
|
|
@@ -171,17 +176,16 @@ async function main({
|
|
|
171
176
|
return {reRenderId}
|
|
172
177
|
}
|
|
173
178
|
|
|
174
|
-
function
|
|
175
|
-
const
|
|
176
|
-
for (let i = 0; i <
|
|
177
|
-
|
|
178
|
-
selector:
|
|
179
|
-
type:
|
|
180
|
-
nodeType: i + 1 < chainedSelectors.length ? chainedSelectors[i + 1] : 'element',
|
|
179
|
+
function normalizeSelectorsToFindRegionsForArray(selectorsToFindRegionsFor) {
|
|
180
|
+
const arr = []
|
|
181
|
+
for (let i = 0; i < selectorsToFindRegionsFor.length; i += 2) {
|
|
182
|
+
arr.push({
|
|
183
|
+
selector: selectorsToFindRegionsFor[i],
|
|
184
|
+
type: selectorsToFindRegionsFor[i + 1],
|
|
181
185
|
})
|
|
182
186
|
}
|
|
183
187
|
|
|
184
|
-
return
|
|
188
|
+
return arr
|
|
185
189
|
}
|
|
186
190
|
|
|
187
191
|
module.exports = main
|
package/src/test-url.js
CHANGED
|
@@ -8,6 +8,7 @@ const createSession = require('./commons/create-session')
|
|
|
8
8
|
const calculateViewRenderingUrl = require('./commons/view-rendering-url')
|
|
9
9
|
const {convertBrowserNameToCanary} = require('./commons/parse-browser')
|
|
10
10
|
const parseJson = require('./commons/parse-json.js')
|
|
11
|
+
const normalizeChainedSelectorsArray = require('./commons/normalizeChainedSelectorsArray')
|
|
11
12
|
|
|
12
13
|
async function main({
|
|
13
14
|
apiKey,
|
|
@@ -16,6 +17,7 @@ async function main({
|
|
|
16
17
|
height,
|
|
17
18
|
target,
|
|
18
19
|
selector,
|
|
20
|
+
chainedSelectors,
|
|
19
21
|
rca,
|
|
20
22
|
iosDeviceName,
|
|
21
23
|
iosDeviceOrientation,
|
|
@@ -32,6 +34,7 @@ async function main({
|
|
|
32
34
|
pns,
|
|
33
35
|
canary,
|
|
34
36
|
options: optionsAsString,
|
|
37
|
+
selectorsToFindRegionsFor,
|
|
35
38
|
}) {
|
|
36
39
|
debug('open done')
|
|
37
40
|
const options = parseJson(optionsAsString, 'options')
|
|
@@ -113,10 +116,18 @@ async function main({
|
|
|
113
116
|
checkWindow({
|
|
114
117
|
snapshot: frame,
|
|
115
118
|
url: frame.url,
|
|
116
|
-
target: selector ? 'region' : target,
|
|
117
|
-
|
|
119
|
+
// target: selector ? 'region' : target,
|
|
120
|
+
sizeMode: selector ? 'region' : target,
|
|
121
|
+
selector: selector
|
|
122
|
+
? {selector, type: selector.startsWith('//') ? 'xpath' : 'css'}
|
|
123
|
+
: chainedSelectors
|
|
124
|
+
? normalizeChainedSelectorsArray(chainedSelectors)
|
|
125
|
+
: undefined,
|
|
118
126
|
sendDom: rca,
|
|
119
127
|
visualGridOptions: options,
|
|
128
|
+
...(selectorsToFindRegionsFor && {
|
|
129
|
+
ignore: normalizeSelectorsToFindRegionsForArray(selectorsToFindRegionsFor),
|
|
130
|
+
}),
|
|
120
131
|
})
|
|
121
132
|
const results = await close(false)
|
|
122
133
|
const result = results[0]
|
|
@@ -141,4 +152,16 @@ async function main({
|
|
|
141
152
|
debug('browser closed')
|
|
142
153
|
}
|
|
143
154
|
|
|
155
|
+
function normalizeSelectorsToFindRegionsForArray(selectorsToFindRegionsFor) {
|
|
156
|
+
const arr = []
|
|
157
|
+
for (let i = 0; i < selectorsToFindRegionsFor.length; i += 2) {
|
|
158
|
+
arr.push({
|
|
159
|
+
selector: selectorsToFindRegionsFor[i],
|
|
160
|
+
type: selectorsToFindRegionsFor[i + 1],
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return arr
|
|
165
|
+
}
|
|
166
|
+
|
|
144
167
|
module.exports = main
|
|
@@ -179,6 +179,11 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
179
179
|
'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>"',
|
|
180
180
|
type: 'array',
|
|
181
181
|
})
|
|
182
|
+
.option('selectors-to-find-regions-for', {
|
|
183
|
+
describe:
|
|
184
|
+
'selectors to find regions for - Specify selectors in the following format: "<selector1>" "xpath || css" <selector2>" "xpath || css"...',
|
|
185
|
+
type: 'array',
|
|
186
|
+
})
|
|
182
187
|
.option('region', {
|
|
183
188
|
describe: 'target a specific region',
|
|
184
189
|
type: 'string',
|
|
@@ -214,6 +219,12 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
214
219
|
type: 'boolean',
|
|
215
220
|
default: false,
|
|
216
221
|
})
|
|
222
|
+
.option('timeout', {
|
|
223
|
+
alias: 't',
|
|
224
|
+
describe: 'Timeout for operation (ms)',
|
|
225
|
+
default: 60000,
|
|
226
|
+
type: 'number',
|
|
227
|
+
})
|
|
217
228
|
.option('options', {
|
|
218
229
|
describe: 'send visual grid options to rendering (json)',
|
|
219
230
|
type: 'string',
|
|
@@ -382,10 +393,20 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
382
393
|
choices: ['viewport', 'full-page', 'selector', 'full-selector'],
|
|
383
394
|
default: 'full-page',
|
|
384
395
|
})
|
|
396
|
+
.option('selectors-to-find-regions-for', {
|
|
397
|
+
describe:
|
|
398
|
+
'selectors to find regions for - Specify selectors in the following format: "<selector1>" "xpath || css" <selector2>" "xpath || css"...',
|
|
399
|
+
type: 'array',
|
|
400
|
+
})
|
|
385
401
|
.option('selector', {
|
|
386
402
|
describe: 'target a specific element (via CSS selector)',
|
|
387
403
|
type: 'string',
|
|
388
404
|
})
|
|
405
|
+
.option('chained-selectors', {
|
|
406
|
+
describe:
|
|
407
|
+
'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>"',
|
|
408
|
+
type: 'array',
|
|
409
|
+
})
|
|
389
410
|
.option('width', {
|
|
390
411
|
describe: 'width of viewport',
|
|
391
412
|
type: 'number',
|