@applitools/visual-grid-cli-utils 1.21.40-FLD-3978.0 → 1.21.41
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,76 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Normalizes chained selectors for selectorsToFindRegionsFor
|
|
5
|
+
* Input can be:
|
|
6
|
+
* - A single array (when flag used once): ["sel1", "nt1", "type1", "sel2", "nt2", "type2"]
|
|
7
|
+
* - An array of arrays (when flag used multiple times): [
|
|
8
|
+
* ["sel1", "nt1", "type1", "sel2", "nt2", "type2"],
|
|
9
|
+
* ["sel3", "nt3", "type3", "sel4", "nt4", "type4"]
|
|
10
|
+
* ]
|
|
11
|
+
*
|
|
12
|
+
* Output: Array of chained selector arrays
|
|
13
|
+
* [
|
|
14
|
+
* [{selector, nodeType, type}, ...],
|
|
15
|
+
* [{selector, nodeType, type}, ...]
|
|
16
|
+
* ]
|
|
17
|
+
*/
|
|
18
|
+
function normalizeChainedSelectorsToFindRegionsForArray(chainedSelectorsInput) {
|
|
19
|
+
if (!chainedSelectorsInput) return []
|
|
20
|
+
|
|
21
|
+
// Check if it's an array of arrays (multiple flag usages) or a single array
|
|
22
|
+
const isMultiple = Array.isArray(chainedSelectorsInput[0])
|
|
23
|
+
|
|
24
|
+
const chainedSelectorsArrays = isMultiple ? chainedSelectorsInput : [chainedSelectorsInput]
|
|
25
|
+
|
|
26
|
+
return chainedSelectorsArrays.map(chainedSelectors => {
|
|
27
|
+
const normalized = []
|
|
28
|
+
|
|
29
|
+
// Process in groups of 3: selector, nodeType, type
|
|
30
|
+
for (let i = 0; i < chainedSelectors.length; i += 3) {
|
|
31
|
+
const selector = chainedSelectors[i]
|
|
32
|
+
const nodeType = chainedSelectors[i + 1]
|
|
33
|
+
const type = chainedSelectors[i + 2]
|
|
34
|
+
|
|
35
|
+
if (!selector) {
|
|
36
|
+
throw new Error(`Missing selector at position ${i} in chained-selectors-to-find-regions-for`)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!nodeType) {
|
|
40
|
+
throw new Error(`Missing nodeType at position ${i + 1} for selector "${selector}"`)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!type) {
|
|
44
|
+
throw new Error(`Missing type at position ${i + 2} for selector "${selector}"`)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Validate nodeType
|
|
48
|
+
if (!['iframe', 'shadow-root', 'element'].includes(nodeType)) {
|
|
49
|
+
throw new Error(`Invalid nodeType "${nodeType}" for selector "${selector}". Must be one of: iframe, shadow-root, element`)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Validate type
|
|
53
|
+
if (!['css', 'xpath'].includes(type)) {
|
|
54
|
+
throw new Error(`Invalid type "${type}" for selector "${selector}". Must be one of: css, xpath`)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
normalized.push({
|
|
58
|
+
selector,
|
|
59
|
+
nodeType,
|
|
60
|
+
type,
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Ensure the last item has nodeType 'element'
|
|
65
|
+
if (normalized.length > 0) {
|
|
66
|
+
const lastItem = normalized[normalized.length - 1]
|
|
67
|
+
if (lastItem.nodeType !== 'element') {
|
|
68
|
+
throw new Error(`The last selector in a chained selector must have nodeType 'element', but got '${lastItem.nodeType}'`)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return normalized
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = normalizeChainedSelectorsToFindRegionsForArray
|
|
@@ -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-poc-canary|edgechromium-canary|firefox|firefox-1|firefox-2|firefox-canary|ie11|ie10|edge|safari|safari-1|safari-2|safari-canary|
|
|
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|webkit|safari-earlyaccess|ie-vmware|edgechromium|edgechromium-1|edgechromium-2|edgechromium-canary|edgelegacy)(\( *(\d+) *(x|,) *(\d+) *\))?$/.exec(
|
|
7
7
|
arg,
|
|
8
8
|
)
|
|
9
9
|
|
package/src/rerender.js
CHANGED
|
@@ -11,6 +11,7 @@ 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
13
|
const normalizeChainedSelectorsArray = require('./commons/normalizeChainedSelectorsArray')
|
|
14
|
+
const normalizeChainedSelectorsToFindRegionsForArray = require('./commons/normalizeChainedSelectorsToFindRegionsForArray')
|
|
14
15
|
|
|
15
16
|
async function main({
|
|
16
17
|
apiKey,
|
|
@@ -46,6 +47,7 @@ async function main({
|
|
|
46
47
|
timeout,
|
|
47
48
|
options: optionsAsString,
|
|
48
49
|
selectorsToFindRegionsFor,
|
|
50
|
+
chainedSelectorsToFindRegionsFor,
|
|
49
51
|
vhsCompatibilityParams,
|
|
50
52
|
globalResourceMapPath,
|
|
51
53
|
originUrl,
|
|
@@ -107,9 +109,19 @@ async function main({
|
|
|
107
109
|
: undefined,
|
|
108
110
|
region: region,
|
|
109
111
|
},
|
|
110
|
-
selectorsToFindRegionsFor:
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
selectorsToFindRegionsFor: (() => {
|
|
113
|
+
const normalizedRegularSelectors = selectorsToFindRegionsFor
|
|
114
|
+
? normalizeSelectorsToFindRegionsForArray(selectorsToFindRegionsFor)
|
|
115
|
+
: []
|
|
116
|
+
|
|
117
|
+
const normalizedChainedSelectors = chainedSelectorsToFindRegionsFor
|
|
118
|
+
? normalizeChainedSelectorsToFindRegionsForArray(chainedSelectorsToFindRegionsFor)
|
|
119
|
+
: []
|
|
120
|
+
|
|
121
|
+
const combined = [...normalizedRegularSelectors, ...normalizedChainedSelectors]
|
|
122
|
+
|
|
123
|
+
return combined.length > 0 ? combined : undefined
|
|
124
|
+
})(),
|
|
113
125
|
enableMultipleResultsPerSelector: true,
|
|
114
126
|
includeFullPageSize,
|
|
115
127
|
sendDom: rca,
|
|
@@ -189,6 +189,11 @@ async function main(argv, {shouldExitOnError = false} = {}) {
|
|
|
189
189
|
'selectors to find regions for - Specify selectors in the following format: "<selector1>" "xpath || css" <selector2>" "xpath || css"...',
|
|
190
190
|
type: 'array',
|
|
191
191
|
})
|
|
192
|
+
.option('chained-selectors-to-find-regions-for', {
|
|
193
|
+
describe:
|
|
194
|
+
'chained selectors to find regions for (can be used multiple times). Specify each chained selector in the following format: --chained-selectors-to-find-regions-for "<selector1>" "<nodeType>" "<type>" "<selector2>" "<nodeType>" "<type>" ...',
|
|
195
|
+
type: 'array',
|
|
196
|
+
})
|
|
192
197
|
.option('region', {
|
|
193
198
|
describe: 'target a specific region',
|
|
194
199
|
type: 'string',
|