@applitools/core 4.21.0 → 4.21.2
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/CHANGELOG.md +56 -0
- package/dist/ufg/take-snapshots.js +3 -25
- package/dist/ufg/utils/generate-safe-selectors.js +7 -30
- package/dist/ufg/utils/take-dom-snapshot.js +53 -16
- package/dist/ufg/utils/take-dom-snapshots.js +5 -19
- package/dist/ufg/utils/to-generated-selectors.js +1 -0
- package/package.json +10 -10
- package/types/ufg/utils/generate-safe-selectors.d.ts +4 -19
- package/types/ufg/utils/take-dom-snapshot.d.ts +7 -13
- package/types/ufg/utils/take-dom-snapshots.d.ts +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.21.2](https://github.com/Applitools-Dev/sdk/compare/js/core@4.21.1...js/core@4.21.2) (2024-10-29)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Dependencies
|
|
7
|
+
|
|
8
|
+
* @applitools/screenshoter bumped to 3.9.2
|
|
9
|
+
#### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* test in screenshoter web ([f068dbe](https://github.com/Applitools-Dev/sdk/commit/f068dbe9036163fb3e316411cfd9f47a226d7c9c))
|
|
12
|
+
|
|
13
|
+
## [4.21.1](https://github.com/Applitools-Dev/sdk/compare/js/core@4.21.0...js/core@4.21.1) (2024-10-28)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* better handling of stale elements ([cab10ff](https://github.com/Applitools-Dev/sdk/commit/cab10ff1ae1e6f9560a7d278c710b3fa03f58c83))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Performance Improvements
|
|
22
|
+
|
|
23
|
+
* avoid logging entire dom snapshots ([#2573](https://github.com/Applitools-Dev/sdk/issues/2573)) ([e6dc792](https://github.com/Applitools-Dev/sdk/commit/e6dc792c75eb39bd4d3e53775b63ba49fad20740))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Dependencies
|
|
27
|
+
|
|
28
|
+
* @applitools/dom-snapshot bumped to 4.11.4
|
|
29
|
+
#### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* better handling of stale elements ([cab10ff](https://github.com/Applitools-Dev/sdk/commit/cab10ff1ae1e6f9560a7d278c710b3fa03f58c83))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
* @applitools/snippets bumped to 2.5.2
|
|
36
|
+
#### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* better handling of stale elements ([cab10ff](https://github.com/Applitools-Dev/sdk/commit/cab10ff1ae1e6f9560a7d278c710b3fa03f58c83))
|
|
39
|
+
* @applitools/driver bumped to 1.19.4
|
|
40
|
+
#### Bug Fixes
|
|
41
|
+
|
|
42
|
+
* better handling of stale elements ([cab10ff](https://github.com/Applitools-Dev/sdk/commit/cab10ff1ae1e6f9560a7d278c710b3fa03f58c83))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
* @applitools/spec-driver-webdriver bumped to 1.1.16
|
|
47
|
+
|
|
48
|
+
* @applitools/spec-driver-selenium bumped to 1.5.87
|
|
49
|
+
|
|
50
|
+
* @applitools/spec-driver-puppeteer bumped to 1.4.16
|
|
51
|
+
|
|
52
|
+
* @applitools/screenshoter bumped to 3.9.1
|
|
53
|
+
|
|
54
|
+
* @applitools/nml-client bumped to 1.8.14
|
|
55
|
+
|
|
56
|
+
* @applitools/ec-client bumped to 1.9.10
|
|
57
|
+
|
|
58
|
+
|
|
3
59
|
## [4.21.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.20.2...js/core@4.21.0) (2024-10-21)
|
|
4
60
|
|
|
5
61
|
|
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.makeTakeSnapshots = void 0;
|
|
27
4
|
const driver_1 = require("@applitools/driver");
|
|
@@ -29,7 +6,6 @@ const take_dom_snapshots_1 = require("./utils/take-dom-snapshots");
|
|
|
29
6
|
const to_safe_check_settings_1 = require("./utils/to-safe-check-settings");
|
|
30
7
|
const to_generated_selectors_1 = require("./utils/to-generated-selectors");
|
|
31
8
|
const abort_error_1 = require("../errors/abort-error");
|
|
32
|
-
const utils = __importStar(require("@applitools/utils"));
|
|
33
9
|
function makeTakeSnapshots({ core, spec, signal, logger: mainLogger }) {
|
|
34
10
|
return async function takeSnapshots({ driver, settings = {}, account, logger = mainLogger, }) {
|
|
35
11
|
var _a;
|
|
@@ -48,6 +24,7 @@ function makeTakeSnapshots({ core, spec, signal, logger: mainLogger }) {
|
|
|
48
24
|
const { elementReferences, getSafeCheckSettings } = (0, to_safe_check_settings_1.toSafeCheckSettings)({ settings });
|
|
49
25
|
const { elementReferencesToMark, getGeneratedSelectors } = (0, to_generated_selectors_1.toGeneratedSelectors)({
|
|
50
26
|
elementReferences,
|
|
27
|
+
// dead code - `transformElementReference` was used for NMG but it's not longer used anywhere
|
|
51
28
|
transformElementReference: elementReference => { var _a; return ((0, driver_1.isSelector)(elementReference) && ((_a = spec === null || spec === void 0 ? void 0 : spec.toSimpleCommonSelector) === null || _a === void 0 ? void 0 : _a.call(spec, elementReference))) || undefined; },
|
|
52
29
|
});
|
|
53
30
|
let snapshots;
|
|
@@ -79,6 +56,7 @@ function makeTakeSnapshots({ core, spec, signal, logger: mainLogger }) {
|
|
|
79
56
|
});
|
|
80
57
|
}
|
|
81
58
|
else {
|
|
59
|
+
// dead code - used for NMG
|
|
82
60
|
const nmlClient = await core.getNMLClient({
|
|
83
61
|
driver,
|
|
84
62
|
settings: { ...account.eyesServer, supportedEnvironmentsUrl: account.supportedEnvironmentsUrl },
|
|
@@ -100,7 +78,7 @@ function makeTakeSnapshots({ core, spec, signal, logger: mainLogger }) {
|
|
|
100
78
|
return snapshots.map((snapshot, index) => ({
|
|
101
79
|
target: snapshot,
|
|
102
80
|
settings: getSafeCheckSettings({
|
|
103
|
-
selectors: getGeneratedSelectors(
|
|
81
|
+
selectors: getGeneratedSelectors(snapshot.generatedSelectors),
|
|
104
82
|
}),
|
|
105
83
|
environment: uniqueEnvironments[index],
|
|
106
84
|
account,
|
|
@@ -25,39 +25,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.generateSafeSelectors = void 0;
|
|
27
27
|
const utils = __importStar(require("@applitools/utils"));
|
|
28
|
-
const { addElementIds
|
|
28
|
+
const { addElementIds } = require('@applitools/snippets');
|
|
29
29
|
async function generateSafeSelectors({ context, elementReferences, }) {
|
|
30
30
|
if (!(elementReferences === null || elementReferences === void 0 ? void 0 : elementReferences.length))
|
|
31
|
-
return;
|
|
32
|
-
const mapping = await Promise.all(elementReferences.map(async (ref) => {
|
|
33
|
-
const elements = await context.elements(ref);
|
|
34
|
-
return {
|
|
35
|
-
ref,
|
|
36
|
-
elements,
|
|
37
|
-
id: utils.general.guid(), // same id for all elements that match the same ref
|
|
38
|
-
};
|
|
39
|
-
}));
|
|
31
|
+
return { generatedSelectors: [] };
|
|
40
32
|
// we can't structure elementsWithIds as object because it's not supported in safari webdriver (https://stackoverflow.com/questions/78953951/ios-safari-webdriver-executescript-fails-to-serialize-objects-with-elements)
|
|
41
|
-
const elementsWithIds =
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (elements.length === 0)
|
|
46
|
-
return { safeSelector: null, originalSelector: null, elementReference: ref };
|
|
47
|
-
const safeSelector = generatedSelectors[offset].reduceRight((selector, value) => {
|
|
48
|
-
return selector ? { type: 'css', selector: value, shadow: selector } : { type: 'css', selector: value };
|
|
49
|
-
}, undefined);
|
|
50
|
-
offset += elements.length;
|
|
51
|
-
return { safeSelector, originalSelector: elements[0].commonSelector, elementReference: ref };
|
|
52
|
-
});
|
|
53
|
-
return {
|
|
54
|
-
selectors,
|
|
55
|
-
cleanupGeneratedSelectors,
|
|
56
|
-
};
|
|
57
|
-
async function cleanupGeneratedSelectors() {
|
|
58
|
-
if (!mapping.length)
|
|
59
|
-
return;
|
|
60
|
-
await context.execute(cleanupElementIds, [mapping.map(({ elements }) => elements).flat()]);
|
|
33
|
+
const elementsWithIds = [];
|
|
34
|
+
for (const ref of elementReferences) {
|
|
35
|
+
const elements = await context.elements(ref);
|
|
36
|
+
elementsWithIds.push([elements, utils.general.guid()]); // same id for all elements that match the same ref
|
|
61
37
|
}
|
|
38
|
+
return { generatedSelectors: await context.execute(addElementIds, elementsWithIds) };
|
|
62
39
|
}
|
|
63
40
|
exports.generateSafeSelectors = generateSafeSelectors;
|
|
@@ -23,24 +23,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.takeDomSnapshot = void 0;
|
|
27
27
|
const utils = __importStar(require("@applitools/utils"));
|
|
28
28
|
const { getProcessPagePoll, getPollResult } = require('@applitools/dom-snapshot');
|
|
29
29
|
async function takeDomSnapshot({ context, settings, logger, }) {
|
|
30
|
-
var _a;
|
|
30
|
+
var _a, _b;
|
|
31
31
|
const driver = context.driver;
|
|
32
32
|
const environment = await driver.getEnvironment();
|
|
33
33
|
const features = await driver.getFeatures();
|
|
34
|
-
const cookies = (
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const cookies = (_a = settings === null || settings === void 0 ? void 0 : settings.cookies) !== null && _a !== void 0 ? _a : [];
|
|
35
|
+
// assumption is that elementReferences are all in the frame which is `context`
|
|
36
|
+
// otherwise, the elements would still be found inside other frames, but `takeContextDomSnapshot` should be passed only the specific element references that it needs
|
|
37
|
+
const elements = [];
|
|
38
|
+
for (const elementReference of (_b = settings === null || settings === void 0 ? void 0 : settings.elementReferences) !== null && _b !== void 0 ? _b : []) {
|
|
39
|
+
elements.push(await context.elements(elementReference));
|
|
40
|
+
}
|
|
41
|
+
const snapshot = transformRawDomSnapshot(await takeContextDomSnapshot({ context }), elements);
|
|
42
|
+
snapshot.cookies = features.allCookies ? await driver.getCookies().catch(() => []) : cookies; // intentionally fetching cookies after the dom snapshot runs
|
|
37
43
|
return snapshot;
|
|
38
44
|
async function takeContextDomSnapshot({ context }) {
|
|
39
45
|
// logger.log(`taking dom snapshot. ${context._reference ? `context referece: ${JSON.stringify(context._reference)}` : ''}`)
|
|
40
46
|
var _a, _b, _c;
|
|
41
|
-
if (!features.allCookies) {
|
|
42
|
-
cookies.push(...(await context.getCookies()));
|
|
43
|
-
}
|
|
44
47
|
const arg = {
|
|
45
48
|
dontFetchResources: settings === null || settings === void 0 ? void 0 : settings.disableBrowserFetching,
|
|
46
49
|
skipResources: settings === null || settings === void 0 ? void 0 : settings.skipResources,
|
|
@@ -50,6 +53,7 @@ async function takeDomSnapshot({ context, settings, logger, }) {
|
|
|
50
53
|
serializeResources: true,
|
|
51
54
|
compressResources: false,
|
|
52
55
|
showLogs: settings === null || settings === void 0 ? void 0 : settings.showLogs,
|
|
56
|
+
elements,
|
|
53
57
|
};
|
|
54
58
|
const scripts = {
|
|
55
59
|
main: features.canExecuteOnlyFunctionScripts
|
|
@@ -65,6 +69,10 @@ async function takeDomSnapshot({ context, settings, logger, }) {
|
|
|
65
69
|
executionTimeout: (_b = settings === null || settings === void 0 ? void 0 : settings.executionTimeout) !== null && _b !== void 0 ? _b : 5 * 60 * 1000,
|
|
66
70
|
pollTimeout: (_c = settings === null || settings === void 0 ? void 0 : settings.pollTimeout) !== null && _c !== void 0 ? _c : 200,
|
|
67
71
|
});
|
|
72
|
+
// intentionally fetching cookies after the dom snapshot runs
|
|
73
|
+
if (!features.allCookies) {
|
|
74
|
+
cookies.push(...(await context.getCookies()));
|
|
75
|
+
}
|
|
68
76
|
const crossFrames = extractCrossFrames({ snapshot, logger });
|
|
69
77
|
for (const { reference, parentSnapshot, cdtNode } of crossFrames) {
|
|
70
78
|
const frameContext = await context
|
|
@@ -88,16 +96,14 @@ async function takeDomSnapshot({ context, settings, logger, }) {
|
|
|
88
96
|
cdtNode.attributes.push({ name: 'data-applitools-src', value: frameSnapshot.url });
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
|
-
logger
|
|
92
|
-
logger.log(`blobs urls (${snapshot.blobs.length}):`, JSON.stringify(snapshot.blobs.map(({ url }) => url)));
|
|
93
|
-
logger.log(`resource urls (${snapshot.resourceUrls.length}):`, JSON.stringify(snapshot.resourceUrls));
|
|
99
|
+
logSnapshot(logger, snapshot);
|
|
94
100
|
return snapshot;
|
|
95
101
|
}
|
|
96
102
|
}
|
|
97
103
|
exports.takeDomSnapshot = takeDomSnapshot;
|
|
98
|
-
function transformRawDomSnapshot(snapshot) {
|
|
99
|
-
const { blobs, selector: _, crossFrames: __, ...rest } = snapshot;
|
|
100
|
-
|
|
104
|
+
function transformRawDomSnapshot(snapshot, elements) {
|
|
105
|
+
const { blobs, safeSelectors, selector: _, crossFrames: __, ...rest } = snapshot;
|
|
106
|
+
const domSnapshot = {
|
|
101
107
|
...rest,
|
|
102
108
|
resourceContents: blobs.reduce((resourceContents, blob) => {
|
|
103
109
|
return {
|
|
@@ -107,6 +113,16 @@ function transformRawDomSnapshot(snapshot) {
|
|
|
107
113
|
}, {}),
|
|
108
114
|
frames: snapshot.frames.map(frameSnapshot => transformRawDomSnapshot(frameSnapshot)),
|
|
109
115
|
};
|
|
116
|
+
if (elements === null || elements === void 0 ? void 0 : elements.length) {
|
|
117
|
+
domSnapshot.generatedSelectors = elements.map((elements, i) => {
|
|
118
|
+
var _a, _b;
|
|
119
|
+
return ({
|
|
120
|
+
originalSelector: (_b = (_a = elements[0]) === null || _a === void 0 ? void 0 : _a.commonSelector) !== null && _b !== void 0 ? _b : null,
|
|
121
|
+
safeSelector: safeSelectors[i],
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return domSnapshot;
|
|
110
126
|
}
|
|
111
127
|
function extractCrossFrames({ snapshot, parent = null, logger, }) {
|
|
112
128
|
var _a;
|
|
@@ -128,7 +144,28 @@ function extractCrossFrames({ snapshot, parent = null, logger, }) {
|
|
|
128
144
|
: []),
|
|
129
145
|
];
|
|
130
146
|
});
|
|
131
|
-
logger.log(
|
|
147
|
+
logger.log(...(snapshot.crossFrames
|
|
148
|
+
? [
|
|
149
|
+
`frames paths for ${JSON.stringify(snapshot.crossFrames)}:`,
|
|
150
|
+
crossFrames.map(selector => ({
|
|
151
|
+
// we don't want `selector.parentSnapshot` to be logged - the size of it can be huge
|
|
152
|
+
cdtNode: selector.cdtNode,
|
|
153
|
+
reference: selector.reference,
|
|
154
|
+
})),
|
|
155
|
+
]
|
|
156
|
+
: ['no cross frames found']));
|
|
132
157
|
return crossFrames;
|
|
133
158
|
}
|
|
134
|
-
|
|
159
|
+
function logSnapshot(logger, snapshot) {
|
|
160
|
+
try {
|
|
161
|
+
logger.log(`dom snapshot cdt length: ${snapshot.cdt.length}`);
|
|
162
|
+
logger.log(`blobs urls (${snapshot.blobs.length}):`, JSON.stringify(snapshot.blobs.map(({ url }) => url)));
|
|
163
|
+
logger.log(`resource urls (${snapshot.resourceUrls.length}):`, JSON.stringify(snapshot.resourceUrls));
|
|
164
|
+
logger.log(`cdt nodes with data-applitools-selector: ${JSON.stringify(snapshot.cdt.filter(node => { var _a; return (_a = node.attributes) === null || _a === void 0 ? void 0 : _a.some(attr => attr.name === 'data-applitools-selector'); }))}`);
|
|
165
|
+
}
|
|
166
|
+
catch (err) {
|
|
167
|
+
logger.error(`error while logging cdt`, err);
|
|
168
|
+
}
|
|
169
|
+
if (snapshot.error)
|
|
170
|
+
logger.error('snapshot error:', snapshot.error);
|
|
171
|
+
}
|
|
@@ -38,7 +38,7 @@ const utils = __importStar(require("@applitools/utils"));
|
|
|
38
38
|
const lang = __importStar(require("../../lang"));
|
|
39
39
|
__exportStar(require("./take-dom-snapshot"), exports);
|
|
40
40
|
async function takeDomSnapshots({ driver, settings, hooks, provides, logger, }) {
|
|
41
|
-
var _a, _b
|
|
41
|
+
var _a, _b;
|
|
42
42
|
// calculating cookies here once so that we (a) don't do it for each dom snapshot, and (b) do it before generating safe selectors
|
|
43
43
|
const features = await driver.getFeatures();
|
|
44
44
|
settings.cookies = features.allCookies ? await driver.getCookies().catch(() => []) : [];
|
|
@@ -50,16 +50,10 @@ async function takeDomSnapshots({ driver, settings, hooks, provides, logger, })
|
|
|
50
50
|
}
|
|
51
51
|
logger.log(`taking single dom snapshot`);
|
|
52
52
|
await beforeEachSnapshot();
|
|
53
|
-
// it's important that we calculate safe selectors as close as possible to taking the dom snapshot
|
|
54
|
-
const safeSelectorResult = await (0, generate_safe_selectors_1.generateSafeSelectors)({
|
|
55
|
-
context: currentContext,
|
|
56
|
-
elementReferences: settings.elementReferences,
|
|
57
|
-
});
|
|
58
53
|
const snapshot = await (0, take_dom_snapshot_1.takeDomSnapshot)({ context: currentContext, settings, logger });
|
|
59
|
-
|
|
60
|
-
return Array(settings.environments.length).fill({ ...snapshot, generatedSelectors: safeSelectorResult === null || safeSelectorResult === void 0 ? void 0 : safeSelectorResult.selectors });
|
|
54
|
+
return Array(settings.environments.length).fill(snapshot);
|
|
61
55
|
}
|
|
62
|
-
const isStrictBreakpoints = utils.types.isArray((
|
|
56
|
+
const isStrictBreakpoints = utils.types.isArray((_b = settings.layoutBreakpoints) === null || _b === void 0 ? void 0 : _b.breakpoints);
|
|
63
57
|
const requiredWidths = await settings.environments.reduce(async (prev, environment, index) => {
|
|
64
58
|
const { name, width } = (await extractEnvironmentInfo(environment));
|
|
65
59
|
const requiredWidths = await prev;
|
|
@@ -92,7 +86,7 @@ async function takeDomSnapshots({ driver, settings, hooks, provides, logger, })
|
|
|
92
86
|
requiredWidths.forEach((browsers, requiredWidth) => entries.push({ viewportSize: { width: requiredWidth, height: initialViewportSize.height }, browsers }));
|
|
93
87
|
logger.log(`All entries to take dom snapshots for`, entries);
|
|
94
88
|
// making safe selectors before any resize in order to make sure fallback selectors are created
|
|
95
|
-
|
|
89
|
+
await (0, generate_safe_selectors_1.generateSafeSelectors)({
|
|
96
90
|
context: currentContext,
|
|
97
91
|
elementReferences: settings.elementReferences,
|
|
98
92
|
});
|
|
@@ -132,22 +126,14 @@ async function takeDomSnapshots({ driver, settings, hooks, provides, logger, })
|
|
|
132
126
|
await (0, wait_for_lazy_load_1.waitForLazyLoad)({ context: currentContext, settings: settings.lazyLoad, logger });
|
|
133
127
|
}
|
|
134
128
|
await beforeEachSnapshot();
|
|
135
|
-
// it's important that we calculate safe selectors as close as possible to taking the dom snapshot
|
|
136
|
-
safeSelectorResult = await (0, generate_safe_selectors_1.generateSafeSelectors)({
|
|
137
|
-
context: currentContext,
|
|
138
|
-
elementReferences: settings.elementReferences,
|
|
139
|
-
});
|
|
140
129
|
const snapshot = await (0, take_dom_snapshot_1.takeDomSnapshot)({ context: currentContext, settings, logger });
|
|
141
|
-
browsers.forEach(({ index }) => (snapshots[index] =
|
|
130
|
+
browsers.forEach(({ index }) => (snapshots[index] = snapshot));
|
|
142
131
|
}
|
|
143
132
|
await driver.setViewportSize(initialViewportSize);
|
|
144
133
|
if (settings.layoutBreakpoints.reload) {
|
|
145
134
|
await driver.reloadPage();
|
|
146
135
|
await beforeEachSnapshot();
|
|
147
136
|
}
|
|
148
|
-
else {
|
|
149
|
-
await (safeSelectorResult === null || safeSelectorResult === void 0 ? void 0 : safeSelectorResult.cleanupGeneratedSelectors());
|
|
150
|
-
}
|
|
151
137
|
return snapshots;
|
|
152
138
|
async function beforeEachSnapshot() {
|
|
153
139
|
var _a, _b;
|
|
@@ -27,6 +27,7 @@ function toGeneratedSelectors({ elementReferences, transformElementReference, })
|
|
|
27
27
|
calculate = generatedSelectors.slice(offset);
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
|
+
// the entire else statement should be a dead code that was used for NMG, will be removed later
|
|
30
31
|
target = elementReferences.target && transformElementReference(elementReferences.target);
|
|
31
32
|
scrolling = elementReferences.scrolling && transformElementReference(elementReferences.scrolling);
|
|
32
33
|
calculate = ((_c = elementReferences.calculate) !== null && _c !== void 0 ? _c : []).map(elementReference => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/core",
|
|
3
|
-
"version": "4.21.
|
|
3
|
+
"version": "4.21.2",
|
|
4
4
|
"homepage": "https://applitools.com",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
|
|
@@ -76,16 +76,16 @@
|
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@applitools/core-base": "1.18.0",
|
|
78
78
|
"@applitools/dom-capture": "11.5.0",
|
|
79
|
-
"@applitools/dom-snapshot": "4.11.
|
|
80
|
-
"@applitools/driver": "1.19.
|
|
81
|
-
"@applitools/ec-client": "1.9.
|
|
79
|
+
"@applitools/dom-snapshot": "4.11.4",
|
|
80
|
+
"@applitools/driver": "1.19.4",
|
|
81
|
+
"@applitools/ec-client": "1.9.10",
|
|
82
82
|
"@applitools/logger": "2.0.18",
|
|
83
|
-
"@applitools/nml-client": "1.8.
|
|
83
|
+
"@applitools/nml-client": "1.8.14",
|
|
84
84
|
"@applitools/req": "1.7.2",
|
|
85
|
-
"@applitools/screenshoter": "3.9.
|
|
86
|
-
"@applitools/snippets": "2.5.
|
|
85
|
+
"@applitools/screenshoter": "3.9.2",
|
|
86
|
+
"@applitools/snippets": "2.5.2",
|
|
87
87
|
"@applitools/socket": "1.1.18",
|
|
88
|
-
"@applitools/spec-driver-webdriver": "1.1.
|
|
88
|
+
"@applitools/spec-driver-webdriver": "1.1.16",
|
|
89
89
|
"@applitools/ufg-client": "1.13.1",
|
|
90
90
|
"@applitools/utils": "1.7.4",
|
|
91
91
|
"@types/ws": "8.5.5",
|
|
@@ -100,8 +100,8 @@
|
|
|
100
100
|
"devDependencies": {
|
|
101
101
|
"@applitools/bongo": "^5.10.0",
|
|
102
102
|
"@applitools/sea": "^1.0.0",
|
|
103
|
-
"@applitools/spec-driver-puppeteer": "^1.4.
|
|
104
|
-
"@applitools/spec-driver-selenium": "^1.5.
|
|
103
|
+
"@applitools/spec-driver-puppeteer": "^1.4.16",
|
|
104
|
+
"@applitools/spec-driver-selenium": "^1.5.87",
|
|
105
105
|
"@applitools/test-server": "^1.2.2",
|
|
106
106
|
"@applitools/test-utils": "^1.5.17",
|
|
107
107
|
"@applitools/tunnel-client": "^1.5.8",
|
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
import { type SpecType, type Context, type ElementReference
|
|
2
|
-
type GeneratedSafeSelector<TSpec extends SpecType> = {
|
|
3
|
-
selectors: {
|
|
4
|
-
safeSelector: CommonSelector | null;
|
|
5
|
-
originalSelector: CommonSelector | null;
|
|
6
|
-
elementReference: ElementReference<TSpec>;
|
|
7
|
-
}[];
|
|
8
|
-
cleanupGeneratedSelectors: () => Promise<void>;
|
|
9
|
-
};
|
|
10
|
-
export declare function generateSafeSelectors<TSpec extends SpecType>({ context, elementReferences, }: {
|
|
11
|
-
context: Context<TSpec>;
|
|
12
|
-
elementReferences: ElementReference<TSpec>[];
|
|
13
|
-
}): Promise<GeneratedSafeSelector<TSpec>>;
|
|
14
|
-
export declare function generateSafeSelectors<TSpec extends SpecType>({ context, elementReferences, }: {
|
|
15
|
-
context: Context<TSpec>;
|
|
16
|
-
elementReferences: undefined | [];
|
|
17
|
-
}): Promise<undefined>;
|
|
1
|
+
import { type SpecType, type Context, type ElementReference } from '@applitools/driver';
|
|
18
2
|
export declare function generateSafeSelectors<TSpec extends SpecType>({ context, elementReferences, }: {
|
|
19
3
|
context: Context<TSpec>;
|
|
20
4
|
elementReferences?: ElementReference<TSpec>[];
|
|
21
|
-
}): Promise<
|
|
22
|
-
|
|
5
|
+
}): Promise<{
|
|
6
|
+
generatedSelectors: string[][][];
|
|
7
|
+
}>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type DomSnapshot } from '../types';
|
|
2
2
|
import { type Logger } from '@applitools/logger';
|
|
3
|
-
import { type SpecType, type Context, type Cookie } from '@applitools/driver';
|
|
3
|
+
import { type SpecType, type Context, type Cookie, type ElementReference, type CommonSelector } from '@applitools/driver';
|
|
4
4
|
export type RawDomSnapshot = {
|
|
5
5
|
url: string;
|
|
6
|
-
selector
|
|
6
|
+
selector?: string;
|
|
7
7
|
cdt: {
|
|
8
8
|
attributes: {
|
|
9
9
|
name: string;
|
|
@@ -22,8 +22,10 @@ export type RawDomSnapshot = {
|
|
|
22
22
|
}[];
|
|
23
23
|
srcAttr: string | null;
|
|
24
24
|
scriptVersion: string;
|
|
25
|
+
safeSelectors?: (CommonSelector | null)[];
|
|
26
|
+
error?: string;
|
|
25
27
|
};
|
|
26
|
-
export type DomSnapshotSettings = {
|
|
28
|
+
export type DomSnapshotSettings<TSpec extends SpecType> = {
|
|
27
29
|
disableBrowserFetching?: boolean;
|
|
28
30
|
skipResources?: string[];
|
|
29
31
|
chunkByteLength?: number;
|
|
@@ -31,18 +33,10 @@ export type DomSnapshotSettings = {
|
|
|
31
33
|
pollTimeout?: number;
|
|
32
34
|
showLogs?: boolean;
|
|
33
35
|
cookies?: Cookie[];
|
|
36
|
+
elementReferences?: ElementReference<TSpec>[];
|
|
34
37
|
};
|
|
35
38
|
export declare function takeDomSnapshot<TSpec extends SpecType>({ context, settings, logger, }: {
|
|
36
39
|
context: Context<TSpec>;
|
|
37
|
-
settings?: DomSnapshotSettings
|
|
40
|
+
settings?: DomSnapshotSettings<TSpec>;
|
|
38
41
|
logger: Logger;
|
|
39
42
|
}): Promise<DomSnapshot>;
|
|
40
|
-
export declare function extractCrossFrames({ snapshot, parent, logger, }: {
|
|
41
|
-
snapshot: RawDomSnapshot;
|
|
42
|
-
parent?: any;
|
|
43
|
-
logger: Logger;
|
|
44
|
-
}): {
|
|
45
|
-
cdtNode: RawDomSnapshot['cdt'][number];
|
|
46
|
-
reference: any;
|
|
47
|
-
parentSnapshot: RawDomSnapshot;
|
|
48
|
-
}[];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { DomSnapshot, LazyLoadOptions } from '../types';
|
|
2
2
|
import { type Size } from '@applitools/utils';
|
|
3
3
|
import { type Logger } from '@applitools/logger';
|
|
4
|
-
import { type SpecType, type Driver
|
|
4
|
+
import { type SpecType, type Driver } from '@applitools/driver';
|
|
5
5
|
import { type Environment } from '@applitools/ufg-client';
|
|
6
6
|
import { type DomSnapshotSettings } from './take-dom-snapshot';
|
|
7
7
|
export * from './take-dom-snapshot';
|
|
8
|
-
export type DomSnapshotsSettings<TSpec extends SpecType> = DomSnapshotSettings & {
|
|
8
|
+
export type DomSnapshotsSettings<TSpec extends SpecType> = DomSnapshotSettings<TSpec> & {
|
|
9
9
|
environments: Environment[];
|
|
10
10
|
waitBeforeCapture?: number | (() => Promise<void>);
|
|
11
11
|
layoutBreakpoints?: {
|
|
@@ -13,7 +13,6 @@ export type DomSnapshotsSettings<TSpec extends SpecType> = DomSnapshotSettings &
|
|
|
13
13
|
reload?: boolean;
|
|
14
14
|
};
|
|
15
15
|
lazyLoad?: boolean | LazyLoadOptions;
|
|
16
|
-
elementReferences?: ElementReference<TSpec>[];
|
|
17
16
|
};
|
|
18
17
|
export declare function takeDomSnapshots<TSpec extends SpecType>({ driver, settings, hooks, provides, logger, }: {
|
|
19
18
|
driver: Driver<TSpec>;
|