@applitools/visual-grid-cli-utils 1.21.15 → 1.21.19
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 +1 -1
- package/src/commons/wait-for-rendering.js +2 -2
- package/src/rerender.js +26 -10
- package/src/test-url.js +16 -0
- package/src/visual-grid-cli-utils.js +20 -0
package/package.json
CHANGED
|
@@ -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
|
@@ -41,7 +41,9 @@ async function main({
|
|
|
41
41
|
viewRendering,
|
|
42
42
|
canary,
|
|
43
43
|
iosVersion,
|
|
44
|
+
timeout,
|
|
44
45
|
options: optionsAsString,
|
|
46
|
+
selectorsToFindRegionsFor,
|
|
45
47
|
}) {
|
|
46
48
|
const options = parseJson(optionsAsString, 'options')
|
|
47
49
|
options.chromeHeadless = headless
|
|
@@ -89,7 +91,9 @@ async function main({
|
|
|
89
91
|
: undefined,
|
|
90
92
|
region: region,
|
|
91
93
|
},
|
|
92
|
-
selectorsToFindRegionsFor:
|
|
94
|
+
selectorsToFindRegionsFor: selectorsToFindRegionsFor
|
|
95
|
+
? normalizeSelectorsToFindRegionsForArray(selectorsToFindRegionsFor)
|
|
96
|
+
: undefined,
|
|
93
97
|
enableMultipleResultsPerSelector: true,
|
|
94
98
|
sendDom: rca,
|
|
95
99
|
agentId: `visual-grid-cli-utils/${require('../package.json').version}`,
|
|
@@ -120,6 +124,7 @@ async function main({
|
|
|
120
124
|
vgUrl,
|
|
121
125
|
reRenderId,
|
|
122
126
|
authToken,
|
|
127
|
+
timeout,
|
|
123
128
|
)
|
|
124
129
|
|
|
125
130
|
if (err) {
|
|
@@ -151,17 +156,16 @@ async function main({
|
|
|
151
156
|
outputFile: domSnapshotHtml,
|
|
152
157
|
})
|
|
153
158
|
|
|
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
|
-
)
|
|
159
|
+
console.log(`\n${domSnapshotOutputFile}: dom capture json`)
|
|
161
160
|
console.log(domSnapshotHtml + ': dom capture rectangles')
|
|
162
161
|
}
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
|
|
163
|
+
if (selectorRegions) {
|
|
164
|
+
console.log('-----')
|
|
165
|
+
console.log(`selector regions output:`)
|
|
166
|
+
console.log(JSON.stringify(selectorRegions, null, 2))
|
|
167
|
+
console.log('-----')
|
|
168
|
+
}
|
|
165
169
|
}
|
|
166
170
|
|
|
167
171
|
if (viewRendering) {
|
|
@@ -184,4 +188,16 @@ function normalizeChainedSelectorsArray(chainedSelectors) {
|
|
|
184
188
|
return cs
|
|
185
189
|
}
|
|
186
190
|
|
|
191
|
+
function normalizeSelectorsToFindRegionsForArray(selectorsToFindRegionsFor) {
|
|
192
|
+
const arr = []
|
|
193
|
+
for (let i = 0; i < selectorsToFindRegionsFor.length; i += 2) {
|
|
194
|
+
arr.push({
|
|
195
|
+
selector: selectorsToFindRegionsFor[i],
|
|
196
|
+
type: selectorsToFindRegionsFor[i + 1],
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return arr
|
|
201
|
+
}
|
|
202
|
+
|
|
187
203
|
module.exports = main
|
package/src/test-url.js
CHANGED
|
@@ -32,6 +32,7 @@ async function main({
|
|
|
32
32
|
pns,
|
|
33
33
|
canary,
|
|
34
34
|
options: optionsAsString,
|
|
35
|
+
selectorsToFindRegionsFor,
|
|
35
36
|
}) {
|
|
36
37
|
debug('open done')
|
|
37
38
|
const options = parseJson(optionsAsString, 'options')
|
|
@@ -117,6 +118,9 @@ async function main({
|
|
|
117
118
|
selector: selector ? {selector, type: selector.startsWith('//') ? 'xpath' : 'css'} : undefined,
|
|
118
119
|
sendDom: rca,
|
|
119
120
|
visualGridOptions: options,
|
|
121
|
+
...(selectorsToFindRegionsFor && {
|
|
122
|
+
ignore: normalizeSelectorsToFindRegionsForArray(selectorsToFindRegionsFor),
|
|
123
|
+
}),
|
|
120
124
|
})
|
|
121
125
|
const results = await close(false)
|
|
122
126
|
const result = results[0]
|
|
@@ -141,4 +145,16 @@ async function main({
|
|
|
141
145
|
debug('browser closed')
|
|
142
146
|
}
|
|
143
147
|
|
|
148
|
+
function normalizeSelectorsToFindRegionsForArray(selectorsToFindRegionsFor) {
|
|
149
|
+
const arr = []
|
|
150
|
+
for (let i = 0; i < selectorsToFindRegionsFor.length; i += 2) {
|
|
151
|
+
arr.push({
|
|
152
|
+
selector: selectorsToFindRegionsFor[i],
|
|
153
|
+
type: selectorsToFindRegionsFor[i + 1],
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return arr
|
|
158
|
+
}
|
|
159
|
+
|
|
144
160
|
module.exports = main
|
|
@@ -154,6 +154,10 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
154
154
|
describe: 'the name of the iOS device to use',
|
|
155
155
|
type: 'string',
|
|
156
156
|
})
|
|
157
|
+
.option('ios-version', {
|
|
158
|
+
describe: 'The iOS version to use (none, latest, latest-1, etc)',
|
|
159
|
+
type: 'string',
|
|
160
|
+
})
|
|
157
161
|
.option('ios-device-orientation', {
|
|
158
162
|
describe: 'screen orientation',
|
|
159
163
|
type: 'string',
|
|
@@ -175,6 +179,11 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
175
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>"',
|
|
176
180
|
type: 'array',
|
|
177
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
|
+
})
|
|
178
187
|
.option('region', {
|
|
179
188
|
describe: 'target a specific region',
|
|
180
189
|
type: 'string',
|
|
@@ -210,6 +219,12 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
210
219
|
type: 'boolean',
|
|
211
220
|
default: false,
|
|
212
221
|
})
|
|
222
|
+
.option('timeout', {
|
|
223
|
+
alias: 't',
|
|
224
|
+
describe: 'Timeout for operation (ms)',
|
|
225
|
+
default: 60000,
|
|
226
|
+
type: 'number',
|
|
227
|
+
})
|
|
213
228
|
.option('options', {
|
|
214
229
|
describe: 'send visual grid options to rendering (json)',
|
|
215
230
|
type: 'string',
|
|
@@ -378,6 +393,11 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
378
393
|
choices: ['viewport', 'full-page', 'selector', 'full-selector'],
|
|
379
394
|
default: 'full-page',
|
|
380
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
|
+
})
|
|
381
401
|
.option('selector', {
|
|
382
402
|
describe: 'target a specific element (via CSS selector)',
|
|
383
403
|
type: 'string',
|