@applitools/visual-grid-cli-utils 1.21.17 → 1.21.21
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,10 @@ async function main({
|
|
|
41
42
|
viewRendering,
|
|
42
43
|
canary,
|
|
43
44
|
iosVersion,
|
|
45
|
+
timeout,
|
|
44
46
|
options: optionsAsString,
|
|
47
|
+
selectorsToFindRegionsFor,
|
|
48
|
+
vhsCompatibilityParams,
|
|
45
49
|
}) {
|
|
46
50
|
const options = parseJson(optionsAsString, 'options')
|
|
47
51
|
options.chromeHeadless = headless
|
|
@@ -71,6 +75,12 @@ async function main({
|
|
|
71
75
|
version: canary ? 'canary' : iosVersion,
|
|
72
76
|
}
|
|
73
77
|
: undefined,
|
|
78
|
+
vhsCompatibilityParams: vhsCompatibilityParams
|
|
79
|
+
? {
|
|
80
|
+
UIKitLinkTimeVersionNumber: vhsCompatibilityParams[0],
|
|
81
|
+
UIKitRunTimeVersionNumber: vhsCompatibilityParams[1],
|
|
82
|
+
}
|
|
83
|
+
: undefined,
|
|
74
84
|
androidDeviceInfo: androidDeviceName
|
|
75
85
|
? {
|
|
76
86
|
name: androidDeviceName,
|
|
@@ -89,7 +99,9 @@ async function main({
|
|
|
89
99
|
: undefined,
|
|
90
100
|
region: region,
|
|
91
101
|
},
|
|
92
|
-
selectorsToFindRegionsFor:
|
|
102
|
+
selectorsToFindRegionsFor: selectorsToFindRegionsFor
|
|
103
|
+
? normalizeSelectorsToFindRegionsForArray(selectorsToFindRegionsFor)
|
|
104
|
+
: undefined,
|
|
93
105
|
enableMultipleResultsPerSelector: true,
|
|
94
106
|
sendDom: rca,
|
|
95
107
|
agentId: `visual-grid-cli-utils/${require('../package.json').version}`,
|
|
@@ -120,6 +132,7 @@ async function main({
|
|
|
120
132
|
vgUrl,
|
|
121
133
|
reRenderId,
|
|
122
134
|
authToken,
|
|
135
|
+
timeout,
|
|
123
136
|
)
|
|
124
137
|
|
|
125
138
|
if (err) {
|
|
@@ -151,15 +164,16 @@ async function main({
|
|
|
151
164
|
outputFile: domSnapshotHtml,
|
|
152
165
|
})
|
|
153
166
|
|
|
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
|
-
)
|
|
167
|
+
console.log(`\n${domSnapshotOutputFile}: dom capture json`)
|
|
161
168
|
console.log(domSnapshotHtml + ': dom capture rectangles')
|
|
162
169
|
}
|
|
170
|
+
|
|
171
|
+
if (selectorRegions) {
|
|
172
|
+
console.log('-----')
|
|
173
|
+
console.log(`selector regions output:`)
|
|
174
|
+
console.log(JSON.stringify(selectorRegions, null, 2))
|
|
175
|
+
console.log('-----')
|
|
176
|
+
}
|
|
163
177
|
}
|
|
164
178
|
|
|
165
179
|
if (viewRendering) {
|
|
@@ -169,17 +183,16 @@ async function main({
|
|
|
169
183
|
return {reRenderId}
|
|
170
184
|
}
|
|
171
185
|
|
|
172
|
-
function
|
|
173
|
-
const
|
|
174
|
-
for (let i = 0; i <
|
|
175
|
-
|
|
176
|
-
selector:
|
|
177
|
-
type:
|
|
178
|
-
nodeType: i + 1 < chainedSelectors.length ? chainedSelectors[i + 1] : 'element',
|
|
186
|
+
function normalizeSelectorsToFindRegionsForArray(selectorsToFindRegionsFor) {
|
|
187
|
+
const arr = []
|
|
188
|
+
for (let i = 0; i < selectorsToFindRegionsFor.length; i += 2) {
|
|
189
|
+
arr.push({
|
|
190
|
+
selector: selectorsToFindRegionsFor[i],
|
|
191
|
+
type: selectorsToFindRegionsFor[i + 1],
|
|
179
192
|
})
|
|
180
193
|
}
|
|
181
194
|
|
|
182
|
-
return
|
|
195
|
+
return arr
|
|
183
196
|
}
|
|
184
197
|
|
|
185
198
|
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
|
|
@@ -170,6 +170,11 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
170
170
|
choices: ['viewport', 'full-page', 'selector', 'full-selector'],
|
|
171
171
|
default: 'full-page',
|
|
172
172
|
})
|
|
173
|
+
.option('vhs-compatibility-params', {
|
|
174
|
+
describe:
|
|
175
|
+
'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',
|
|
176
|
+
type: 'array',
|
|
177
|
+
})
|
|
173
178
|
.option('selector', {
|
|
174
179
|
describe: 'target a specific element (via CSS selector)',
|
|
175
180
|
type: 'string',
|
|
@@ -179,6 +184,11 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
179
184
|
'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
185
|
type: 'array',
|
|
181
186
|
})
|
|
187
|
+
.option('selectors-to-find-regions-for', {
|
|
188
|
+
describe:
|
|
189
|
+
'selectors to find regions for - Specify selectors in the following format: "<selector1>" "xpath || css" <selector2>" "xpath || css"...',
|
|
190
|
+
type: 'array',
|
|
191
|
+
})
|
|
182
192
|
.option('region', {
|
|
183
193
|
describe: 'target a specific region',
|
|
184
194
|
type: 'string',
|
|
@@ -214,6 +224,12 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
214
224
|
type: 'boolean',
|
|
215
225
|
default: false,
|
|
216
226
|
})
|
|
227
|
+
.option('timeout', {
|
|
228
|
+
alias: 't',
|
|
229
|
+
describe: 'Timeout for operation (ms)',
|
|
230
|
+
default: 60000,
|
|
231
|
+
type: 'number',
|
|
232
|
+
})
|
|
217
233
|
.option('options', {
|
|
218
234
|
describe: 'send visual grid options to rendering (json)',
|
|
219
235
|
type: 'string',
|
|
@@ -382,10 +398,20 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
382
398
|
choices: ['viewport', 'full-page', 'selector', 'full-selector'],
|
|
383
399
|
default: 'full-page',
|
|
384
400
|
})
|
|
401
|
+
.option('selectors-to-find-regions-for', {
|
|
402
|
+
describe:
|
|
403
|
+
'selectors to find regions for - Specify selectors in the following format: "<selector1>" "xpath || css" <selector2>" "xpath || css"...',
|
|
404
|
+
type: 'array',
|
|
405
|
+
})
|
|
385
406
|
.option('selector', {
|
|
386
407
|
describe: 'target a specific element (via CSS selector)',
|
|
387
408
|
type: 'string',
|
|
388
409
|
})
|
|
410
|
+
.option('chained-selectors', {
|
|
411
|
+
describe:
|
|
412
|
+
'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>"',
|
|
413
|
+
type: 'array',
|
|
414
|
+
})
|
|
389
415
|
.option('width', {
|
|
390
416
|
describe: 'width of viewport',
|
|
391
417
|
type: 'number',
|