@applitools/visual-grid-cli-utils 1.21.18 → 1.21.22
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
|
|
@@ -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/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,
|
|
@@ -39,10 +40,13 @@ async function main({
|
|
|
39
40
|
rca,
|
|
40
41
|
native,
|
|
41
42
|
viewRendering,
|
|
43
|
+
includeFullPageSize,
|
|
42
44
|
canary,
|
|
43
45
|
iosVersion,
|
|
44
46
|
timeout,
|
|
45
47
|
options: optionsAsString,
|
|
48
|
+
selectorsToFindRegionsFor,
|
|
49
|
+
vhsCompatibilityParams,
|
|
46
50
|
}) {
|
|
47
51
|
const options = parseJson(optionsAsString, 'options')
|
|
48
52
|
options.chromeHeadless = headless
|
|
@@ -72,6 +76,12 @@ async function main({
|
|
|
72
76
|
version: canary ? 'canary' : iosVersion,
|
|
73
77
|
}
|
|
74
78
|
: undefined,
|
|
79
|
+
vhsCompatibilityParams: vhsCompatibilityParams
|
|
80
|
+
? {
|
|
81
|
+
UIKitLinkTimeVersionNumber: vhsCompatibilityParams[0],
|
|
82
|
+
UIKitRunTimeVersionNumber: vhsCompatibilityParams[1],
|
|
83
|
+
}
|
|
84
|
+
: undefined,
|
|
75
85
|
androidDeviceInfo: androidDeviceName
|
|
76
86
|
? {
|
|
77
87
|
name: androidDeviceName,
|
|
@@ -90,8 +100,11 @@ async function main({
|
|
|
90
100
|
: undefined,
|
|
91
101
|
region: region,
|
|
92
102
|
},
|
|
93
|
-
selectorsToFindRegionsFor:
|
|
103
|
+
selectorsToFindRegionsFor: selectorsToFindRegionsFor
|
|
104
|
+
? normalizeSelectorsToFindRegionsForArray(selectorsToFindRegionsFor)
|
|
105
|
+
: undefined,
|
|
94
106
|
enableMultipleResultsPerSelector: true,
|
|
107
|
+
includeFullPageSize,
|
|
95
108
|
sendDom: rca,
|
|
96
109
|
agentId: `visual-grid-cli-utils/${require('../package.json').version}`,
|
|
97
110
|
// browser: {
|
|
@@ -117,7 +130,7 @@ async function main({
|
|
|
117
130
|
|
|
118
131
|
const {renderId: reRenderId} = await response.json()
|
|
119
132
|
|
|
120
|
-
const [err, imageLocation, domLocation, selectorRegions] = await waitForRendering(
|
|
133
|
+
const [err, imageLocation, domLocation, selectorRegions, fullPageSize] = await waitForRendering(
|
|
121
134
|
vgUrl,
|
|
122
135
|
reRenderId,
|
|
123
136
|
authToken,
|
|
@@ -153,35 +166,42 @@ async function main({
|
|
|
153
166
|
outputFile: domSnapshotHtml,
|
|
154
167
|
})
|
|
155
168
|
|
|
156
|
-
console.log(
|
|
157
|
-
`\n${domSnapshotOutputFile}: dom capture json${
|
|
158
|
-
selectorRegions && selectorRegions.length > 0 && selectorRegions[0].length > 0
|
|
159
|
-
? `, at offset ${selectorRegions[0][0].x},${selectorRegions[0][0].y}`
|
|
160
|
-
: ''
|
|
161
|
-
}`,
|
|
162
|
-
)
|
|
169
|
+
console.log(`\n${domSnapshotOutputFile}: dom capture json`)
|
|
163
170
|
console.log(domSnapshotHtml + ': dom capture rectangles')
|
|
164
171
|
}
|
|
172
|
+
|
|
173
|
+
if (selectorRegions) {
|
|
174
|
+
console.log('-----')
|
|
175
|
+
console.log(`selector regions output:`)
|
|
176
|
+
console.log(JSON.stringify(selectorRegions, null, 2))
|
|
177
|
+
console.log('-----')
|
|
178
|
+
}
|
|
165
179
|
}
|
|
166
180
|
|
|
167
181
|
if (viewRendering) {
|
|
168
182
|
console.log('\n' + calculateViewRenderingUrl(renderId, authToken))
|
|
169
183
|
}
|
|
170
184
|
|
|
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
|
+
|
|
171
192
|
return {reRenderId}
|
|
172
193
|
}
|
|
173
194
|
|
|
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',
|
|
195
|
+
function normalizeSelectorsToFindRegionsForArray(selectorsToFindRegionsFor) {
|
|
196
|
+
const arr = []
|
|
197
|
+
for (let i = 0; i < selectorsToFindRegionsFor.length; i += 2) {
|
|
198
|
+
arr.push({
|
|
199
|
+
selector: selectorsToFindRegionsFor[i],
|
|
200
|
+
type: selectorsToFindRegionsFor[i + 1],
|
|
181
201
|
})
|
|
182
202
|
}
|
|
183
203
|
|
|
184
|
-
return
|
|
204
|
+
return arr
|
|
185
205
|
}
|
|
186
206
|
|
|
187
207
|
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('includeFullPageSize', {
|
|
228
|
+
alias: 'f',
|
|
229
|
+
describe: 'output the full page size after rendering',
|
|
230
|
+
type: 'boolean',
|
|
231
|
+
default: false,
|
|
232
|
+
})
|
|
217
233
|
.option('timeout', {
|
|
218
234
|
alias: 't',
|
|
219
235
|
describe: 'Timeout for operation (ms)',
|
|
@@ -388,10 +404,20 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
388
404
|
choices: ['viewport', 'full-page', 'selector', 'full-selector'],
|
|
389
405
|
default: 'full-page',
|
|
390
406
|
})
|
|
407
|
+
.option('selectors-to-find-regions-for', {
|
|
408
|
+
describe:
|
|
409
|
+
'selectors to find regions for - Specify selectors in the following format: "<selector1>" "xpath || css" <selector2>" "xpath || css"...',
|
|
410
|
+
type: 'array',
|
|
411
|
+
})
|
|
391
412
|
.option('selector', {
|
|
392
413
|
describe: 'target a specific element (via CSS selector)',
|
|
393
414
|
type: 'string',
|
|
394
415
|
})
|
|
416
|
+
.option('chained-selectors', {
|
|
417
|
+
describe:
|
|
418
|
+
'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>"',
|
|
419
|
+
type: 'array',
|
|
420
|
+
})
|
|
395
421
|
.option('width', {
|
|
396
422
|
describe: 'width of viewport',
|
|
397
423
|
type: 'number',
|