@applitools/eyes-testcafe 2.0.0-beta.9 → 3.0.0
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 +540 -0
- package/LICENSE +1 -1
- package/README.md +7 -531
- package/dist/api.js +51 -0
- package/dist/extract-environment.js +15 -0
- package/dist/index-legacy.js +5 -0
- package/dist/index.js +19 -0
- package/dist/legacy.js +225 -0
- package/dist/spec-driver.js +245 -0
- package/package.json +73 -77
- package/types/index-legacy.d.ts +2 -0
- package/types/index.d.ts +1833 -0
- package/dist/captureFrameAndPoll.js +0 -1468
- package/dist/captureFrameAndPollForIE.js +0 -12569
- package/index.js +0 -30
- package/lib/BordersAwareElementContentLocationProvider.js +0 -79
- package/lib/Eyes.js +0 -927
- package/lib/EyesFactory.js +0 -73
- package/lib/EyesTestCafe.js +0 -1277
- package/lib/EyesTestcafeUtils.js +0 -440
- package/lib/EyesVisualGrid.js +0 -345
- package/lib/ImageOrientationHandler.js +0 -31
- package/lib/JavascriptHandler.js +0 -20
- package/lib/TestCafeExecutor.js +0 -57
- package/lib/capture/EyesWebDriverScreenshot.js +0 -650
- package/lib/capture/EyesWebDriverScreenshotFactory.js +0 -32
- package/lib/capture/FirefoxScreenshotImageProvider.js +0 -63
- package/lib/capture/ImageProviderFactory.js +0 -38
- package/lib/capture/SafariScreenshotImageProvider.js +0 -254
- package/lib/capture/TakesScreenshotImageProvider.js +0 -35
- package/lib/errors/EyesDriverOperationError.js +0 -10
- package/lib/errors/NoFramesError.js +0 -7
- package/lib/fluent/AccessibilityRegionByElement.js +0 -46
- package/lib/fluent/AccessibilityRegionBySelector.js +0 -58
- package/lib/fluent/FloatingRegionByElement.js +0 -56
- package/lib/fluent/FloatingRegionBySelector.js +0 -63
- package/lib/fluent/FrameLocator.js +0 -110
- package/lib/fluent/IgnoreRegionByElement.js +0 -51
- package/lib/fluent/IgnoreRegionBySelector.js +0 -57
- package/lib/fluent/SelectorByElement.js +0 -37
- package/lib/fluent/SelectorByLocator.js +0 -47
- package/lib/fluent/Target.js +0 -17
- package/lib/fluent/TestcafeCheckSettings.js +0 -352
- package/lib/frames/Frame.js +0 -149
- package/lib/frames/FrameChain.js +0 -175
- package/lib/getCaptureDomScript.js +0 -14
- package/lib/hash.js +0 -15
- package/lib/isTestcafeSelector.js +0 -7
- package/lib/makeClientFunctionWrapper.js +0 -61
- package/lib/positioning/CssTranslatePositionMemento.js +0 -39
- package/lib/positioning/CssTranslatePositionProvider.js +0 -130
- package/lib/positioning/ElementPositionMemento.js +0 -36
- package/lib/positioning/ElementPositionProvider.js +0 -88
- package/lib/positioning/FirefoxRegionPositionCompensation.js +0 -45
- package/lib/positioning/ImageRotation.js +0 -22
- package/lib/positioning/OverflowAwareCssTranslatePositionProvider.js +0 -17
- package/lib/positioning/OverflowAwareScrollPositionProvider.js +0 -17
- package/lib/positioning/RegionPositionCompensationFactory.js +0 -37
- package/lib/positioning/SafariRegionPositionCompensation.js +0 -26
- package/lib/positioning/ScrollPositionMemento.js +0 -36
- package/lib/positioning/ScrollPositionProvider.js +0 -118
- package/lib/positioning/fixImageMarkPosition.js +0 -36
- package/lib/regionVisibility/MoveToRegionVisibilityStrategy.js +0 -55
- package/lib/regionVisibility/NopRegionVisibilityStrategy.js +0 -35
- package/lib/regionVisibility/RegionVisibilityStrategy.js +0 -30
- package/lib/runner/ClassicRunner.js +0 -49
- package/lib/runner/EyesRunner.js +0 -41
- package/lib/runner/TestResultContainer.js +0 -38
- package/lib/runner/TestResultsSummary.js +0 -112
- package/lib/runner/VisualGridRunner.js +0 -57
- package/lib/safeExecuteFunction.js +0 -28
- package/lib/wrappers/EyesTargetLocator.js +0 -335
- package/lib/wrappers/EyesWebDriver.js +0 -571
- package/lib/wrappers/EyesWebElement.js +0 -383
- package/lib/wrappers/EyesWebElementPromise.js +0 -68
package/dist/legacy.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformCheckSettings = exports.transformConfig = exports.LegacyTestCafeEyesMixin = void 0;
|
|
4
|
+
const core_1 = require("@applitools/core");
|
|
5
|
+
const eyes = require("@applitools/eyes");
|
|
6
|
+
const utils = require("@applitools/utils");
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const spec = require("./spec-driver");
|
|
10
|
+
function LegacyTestCafeEyesMixin(Eyes) {
|
|
11
|
+
return class TestCafeEyes extends Eyes {
|
|
12
|
+
constructor(runnerOrConfigOrOptions, configOrRunner) {
|
|
13
|
+
var _a, _b, _c;
|
|
14
|
+
if (utils.types.isNull(runnerOrConfigOrOptions) || utils.types.has(runnerOrConfigOrOptions, 'configPath')) {
|
|
15
|
+
const testcafeConfig = utils.config.getConfig({
|
|
16
|
+
paths: (runnerOrConfigOrOptions === null || runnerOrConfigOrOptions === void 0 ? void 0 : runnerOrConfigOrOptions.configPath) ? [runnerOrConfigOrOptions.configPath] : undefined,
|
|
17
|
+
params: ['failTestcafeOnDiff'],
|
|
18
|
+
});
|
|
19
|
+
const runner = (_a = runnerOrConfigOrOptions === null || runnerOrConfigOrOptions === void 0 ? void 0 : runnerOrConfigOrOptions.runner) !== null && _a !== void 0 ? _a : new eyes.VisualGridRunner({
|
|
20
|
+
testConcurrency: (_c = (_b = testcafeConfig.concurrency) !== null && _b !== void 0 ? _b : testcafeConfig.testConcurrency) !== null && _c !== void 0 ? _c : 1,
|
|
21
|
+
});
|
|
22
|
+
super(runner, transformConfig(testcafeConfig));
|
|
23
|
+
this._testcafeConfig = testcafeConfig;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
super(runnerOrConfigOrOptions, configOrRunner);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async open(driverOrConfigOrAppNameOrOptions, configOrAppNameOrTestName, testNameOrViewportSize, viewportSizeOrSessionType, sessionType) {
|
|
30
|
+
var _a;
|
|
31
|
+
let driver, config;
|
|
32
|
+
if (spec.isDriver(driverOrConfigOrAppNameOrOptions)) {
|
|
33
|
+
driver = driverOrConfigOrAppNameOrOptions;
|
|
34
|
+
config = utils.types.isString(configOrAppNameOrTestName)
|
|
35
|
+
? {
|
|
36
|
+
appName: configOrAppNameOrTestName,
|
|
37
|
+
testName: testNameOrViewportSize,
|
|
38
|
+
viewportSize: viewportSizeOrSessionType,
|
|
39
|
+
sessionType,
|
|
40
|
+
}
|
|
41
|
+
: configOrAppNameOrTestName;
|
|
42
|
+
}
|
|
43
|
+
else if (utils.types.has(driverOrConfigOrAppNameOrOptions, 't')) {
|
|
44
|
+
const { t, ...testcafeConfig } = driverOrConfigOrAppNameOrOptions;
|
|
45
|
+
this._testcafeConfig = { ...this._testcafeConfig, ...testcafeConfig };
|
|
46
|
+
driver = t;
|
|
47
|
+
config = transformConfig(this._testcafeConfig);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
config = utils.types.isString(configOrAppNameOrTestName)
|
|
51
|
+
? {
|
|
52
|
+
appName: configOrAppNameOrTestName,
|
|
53
|
+
testName: testNameOrViewportSize,
|
|
54
|
+
viewportSize: viewportSizeOrSessionType,
|
|
55
|
+
sessionType,
|
|
56
|
+
}
|
|
57
|
+
: configOrAppNameOrTestName;
|
|
58
|
+
}
|
|
59
|
+
if ((_a = this._testcafeConfig) === null || _a === void 0 ? void 0 : _a.showLogs)
|
|
60
|
+
this.setLogHandler({ type: 'console' });
|
|
61
|
+
if (driver) {
|
|
62
|
+
// driver health check, re: https://trello.com/c/xNCZNfPi
|
|
63
|
+
await spec
|
|
64
|
+
.executeScript(driver, () => true)
|
|
65
|
+
.catch(() => {
|
|
66
|
+
throw new Error(`The browser is in an invalid state due to JS errors on the page that TestCafe is unable to handle. Try running the test with TestCafe's --skip-js-errors option enabled: https://devexpress.github.io/testcafe/documentation/reference/configuration-file.html#skipjserrors`);
|
|
67
|
+
});
|
|
68
|
+
config;
|
|
69
|
+
return super.open(driver, config);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return super.open(config);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async checkWindow(nameOrSetting, timeout, fully = true) {
|
|
76
|
+
if (utils.types.isObject(nameOrSetting)) {
|
|
77
|
+
return super.check(transformCheckSettings(nameOrSetting));
|
|
78
|
+
}
|
|
79
|
+
return super.checkWindow(nameOrSetting, timeout, fully);
|
|
80
|
+
}
|
|
81
|
+
async close(throwErr = true) {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
return super.close(throwErr && ((_b = (_a = this._testcafeConfig) === null || _a === void 0 ? void 0 : _a.failTestcafeOnDiff) !== null && _b !== void 0 ? _b : true));
|
|
84
|
+
}
|
|
85
|
+
async waitForResults(throwErr = true) {
|
|
86
|
+
var _a, _b, _c;
|
|
87
|
+
const resultsSummary = await this.runner.getAllTestResults(throwErr && ((_b = (_a = this._testcafeConfig) === null || _a === void 0 ? void 0 : _a.failTestcafeOnDiff) !== null && _b !== void 0 ? _b : true));
|
|
88
|
+
if ((_c = this._testcafeConfig) === null || _c === void 0 ? void 0 : _c.tapDirPath) {
|
|
89
|
+
const results = resultsSummary.getAllResults().map(r => r.getTestResults());
|
|
90
|
+
const formatted = core_1.formatters.toHierarchicTAPString(results, {
|
|
91
|
+
includeSubTests: false,
|
|
92
|
+
markNewAsPassed: true,
|
|
93
|
+
});
|
|
94
|
+
fs.writeFileSync(path.resolve(this._testcafeConfig.tapDirPath, 'eyes.tap'), formatted);
|
|
95
|
+
}
|
|
96
|
+
return resultsSummary;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
exports.LegacyTestCafeEyesMixin = LegacyTestCafeEyesMixin;
|
|
101
|
+
function transformConfig(options) {
|
|
102
|
+
const config = { ...options };
|
|
103
|
+
if (options.concurrency)
|
|
104
|
+
config.concurrentSessions = options.concurrency;
|
|
105
|
+
if (options.envName) {
|
|
106
|
+
config.environmentName = options.envName;
|
|
107
|
+
delete config.envName;
|
|
108
|
+
}
|
|
109
|
+
if (options.browser) {
|
|
110
|
+
config.browsersInfo = utils.types.isArray(options.browser) ? options.browser : [options.browser];
|
|
111
|
+
delete config.browser;
|
|
112
|
+
}
|
|
113
|
+
if (options.batchId ||
|
|
114
|
+
options.batchName ||
|
|
115
|
+
options.notifyOnCompletion ||
|
|
116
|
+
process.env.APPLITOOLS_NOTIFY_ON_COMPLETION) {
|
|
117
|
+
config.batch = {
|
|
118
|
+
id: options.batchId,
|
|
119
|
+
name: options.batchName,
|
|
120
|
+
notifyOnCompletion: options.notifyOnCompletion || !!process.env.APPLITOOLS_NOTIFY_ON_COMPLETION,
|
|
121
|
+
};
|
|
122
|
+
delete config.batchId;
|
|
123
|
+
delete config.batchName;
|
|
124
|
+
delete config.notifyOnCompletion;
|
|
125
|
+
}
|
|
126
|
+
if (options.matchLevel || options.ignoreCaret || options.ignoreDisplacements || options.accessibilityValidation) {
|
|
127
|
+
config.defaultMatchSettings = {
|
|
128
|
+
ignoreCaret: options.ignoreCaret,
|
|
129
|
+
matchLevel: options.matchLevel,
|
|
130
|
+
ignoreDisplacements: options.ignoreDisplacements,
|
|
131
|
+
accessibilitySettings: options.accessibilityValidation,
|
|
132
|
+
};
|
|
133
|
+
delete config.ignoreCaret;
|
|
134
|
+
delete config.matchLevel;
|
|
135
|
+
delete config.ignoreDisplacements;
|
|
136
|
+
delete config.accessibilityValidation;
|
|
137
|
+
}
|
|
138
|
+
if (utils.types.isString(options.proxy)) {
|
|
139
|
+
config.proxy = { url: options.proxy };
|
|
140
|
+
}
|
|
141
|
+
return config;
|
|
142
|
+
}
|
|
143
|
+
exports.transformConfig = transformConfig;
|
|
144
|
+
function transformCheckSettings(options) {
|
|
145
|
+
var _a;
|
|
146
|
+
const settings = { ...options };
|
|
147
|
+
settings.name = options.tag;
|
|
148
|
+
settings.hooks = options.scriptHooks;
|
|
149
|
+
settings.fully = (_a = options.fully) !== null && _a !== void 0 ? _a : options.target !== 'region';
|
|
150
|
+
if (options.target && options.target === 'region' && options.selector) {
|
|
151
|
+
settings.region = options.selector;
|
|
152
|
+
}
|
|
153
|
+
if (options.accessibility) {
|
|
154
|
+
const accessibilityRegions = utils.types.isArray(options.accessibility)
|
|
155
|
+
? options.accessibility
|
|
156
|
+
: [options.accessibility];
|
|
157
|
+
settings.accessibilityRegions = accessibilityRegions.map(accessibilityRegion => {
|
|
158
|
+
const { accessibilityType, ...region } = accessibilityRegion;
|
|
159
|
+
if (utils.types.has(region, 'selector') && !utils.types.has(region, 'type')) {
|
|
160
|
+
return { region: region.selector, accessibilityType };
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
return { region, accessibilityType };
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
if (options.floating) {
|
|
168
|
+
const floatingRegions = utils.types.isArray(options.floating) ? options.floating : [options.floating];
|
|
169
|
+
settings.floatingRegions = floatingRegions.map(floatingRegion => {
|
|
170
|
+
const { maxUpOffset, maxDownOffset, maxLeftOffset, maxRightOffset, ...region } = floatingRegion;
|
|
171
|
+
if (utils.types.has(region, 'selector') && !utils.types.has(region, 'type')) {
|
|
172
|
+
return { maxUpOffset, maxDownOffset, maxLeftOffset, maxRightOffset, region: region.selector };
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
return { maxUpOffset, maxDownOffset, maxLeftOffset, maxRightOffset, region };
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
if (options.ignore) {
|
|
180
|
+
const ignoreRegions = utils.types.isArray(options.ignore) ? options.ignore : [options.ignore];
|
|
181
|
+
settings.ignoreRegions = ignoreRegions.map(region => {
|
|
182
|
+
if (utils.types.has(region, 'selector') && !utils.types.has(region, 'type')) {
|
|
183
|
+
return region.selector;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
return region;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
if (options.layout) {
|
|
191
|
+
const layoutRegions = utils.types.isArray(options.layout) ? options.layout : [options.layout];
|
|
192
|
+
settings.layoutRegions = layoutRegions.map(region => {
|
|
193
|
+
if (utils.types.has(region, 'selector') && !utils.types.has(region, 'type')) {
|
|
194
|
+
return region.selector;
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
return region;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (options.strict) {
|
|
202
|
+
const strictRegions = utils.types.isArray(options.strict) ? options.strict : [options.strict];
|
|
203
|
+
settings.strictRegions = strictRegions.map(region => {
|
|
204
|
+
if (utils.types.has(region, 'selector') && !utils.types.has(region, 'type')) {
|
|
205
|
+
return region.selector;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
return region;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
if (options.content) {
|
|
213
|
+
const contentRegions = utils.types.isArray(options.content) ? options.content : [options.content];
|
|
214
|
+
settings.contentRegions = contentRegions.map(region => {
|
|
215
|
+
if (utils.types.has(region, 'selector') && !utils.types.has(region, 'type')) {
|
|
216
|
+
return region.selector;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
return region;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return settings;
|
|
224
|
+
}
|
|
225
|
+
exports.transformCheckSettings = transformCheckSettings;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.takeScreenshot = exports.visit = exports.getUrl = exports.getTitle = exports.setViewportSize = exports.getDriverInfo = exports.childContext = exports.mainContext = exports.hover = exports.setElementText = exports.click = exports.findElements = exports.findElement = exports.executeScript = exports.extractSelector = exports.toSelector = exports.toElement = exports.isSelector = exports.isSecondaryElement = exports.isElement = exports.isDriver = void 0;
|
|
4
|
+
const testcafe = require("testcafe");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const utils = require("@applitools/utils");
|
|
7
|
+
function XPathSelector(selector, options) {
|
|
8
|
+
const getElementsByXPath = testcafe.Selector(xpath => {
|
|
9
|
+
/* eslint-disable no-undef */
|
|
10
|
+
const iterator = document.evaluate(xpath, document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
|
|
11
|
+
/* eslint-enable */
|
|
12
|
+
const items = [];
|
|
13
|
+
let item = iterator.iterateNext();
|
|
14
|
+
while (item) {
|
|
15
|
+
items.push(item);
|
|
16
|
+
item = iterator.iterateNext();
|
|
17
|
+
}
|
|
18
|
+
return items;
|
|
19
|
+
}, options);
|
|
20
|
+
return testcafe.Selector(getElementsByXPath(selector), options);
|
|
21
|
+
}
|
|
22
|
+
function deserializeResult(result, elements) {
|
|
23
|
+
if (!result) {
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
else if (result.isElement) {
|
|
27
|
+
return elements.shift();
|
|
28
|
+
}
|
|
29
|
+
else if (utils.types.isArray(result)) {
|
|
30
|
+
return result.map(result => deserializeResult(result, elements));
|
|
31
|
+
}
|
|
32
|
+
else if (utils.types.isObject(result)) {
|
|
33
|
+
return Object.entries(result).reduce((object, [key, value]) => {
|
|
34
|
+
return Object.assign(object, { [key]: deserializeResult(value, elements) });
|
|
35
|
+
}, {});
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const scriptRunner = testcafe.ClientFunction(() => {
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
const { script, arg } = input;
|
|
44
|
+
const func = new Function(script.startsWith('function') ? `return (${script}).apply(null, arguments)` : script);
|
|
45
|
+
const elements = [];
|
|
46
|
+
const result = serializeResult(func(deserializeArg(arg)));
|
|
47
|
+
const resultId = elements.length > 0 ? String(Math.floor(Math.random() * 1000)) : null;
|
|
48
|
+
if (resultId) {
|
|
49
|
+
const APPLITOOLS_NAMESPACE = '__TESTCAFE_EYES_APPLITOOLS__';
|
|
50
|
+
const global = window;
|
|
51
|
+
if (!global[APPLITOOLS_NAMESPACE])
|
|
52
|
+
global[APPLITOOLS_NAMESPACE] = {};
|
|
53
|
+
global[APPLITOOLS_NAMESPACE][resultId] = elements;
|
|
54
|
+
}
|
|
55
|
+
return { result, resultId, elementsCount: elements.length };
|
|
56
|
+
function deserializeArg(arg) {
|
|
57
|
+
if (!arg) {
|
|
58
|
+
return arg;
|
|
59
|
+
}
|
|
60
|
+
else if (typeof arg === 'function') {
|
|
61
|
+
return arg();
|
|
62
|
+
}
|
|
63
|
+
else if (Array.isArray(arg)) {
|
|
64
|
+
return arg.map(deserializeArg);
|
|
65
|
+
}
|
|
66
|
+
else if (typeof arg === 'object') {
|
|
67
|
+
return Object.entries(arg).reduce((object, [key, value]) => {
|
|
68
|
+
return Object.assign(object, { [key]: deserializeArg(value) });
|
|
69
|
+
}, {});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return arg;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function serializeResult(result) {
|
|
76
|
+
if (!result) {
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
else if (result instanceof window.HTMLElement) {
|
|
80
|
+
elements.push(result);
|
|
81
|
+
return { isElement: true };
|
|
82
|
+
}
|
|
83
|
+
else if (Array.isArray(result)) {
|
|
84
|
+
return result.map(serializeResult);
|
|
85
|
+
}
|
|
86
|
+
else if (typeof result === 'object') {
|
|
87
|
+
return Object.entries(result).reduce((object, [key, value]) => {
|
|
88
|
+
return Object.assign(object, { [key]: serializeResult(value) });
|
|
89
|
+
}, {});
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
const elementsExtractor = testcafe.Selector(() => {
|
|
97
|
+
// @ts-ignore
|
|
98
|
+
const { resultId } = input;
|
|
99
|
+
const APPLITOOLS_NAMESPACE = '__TESTCAFE_EYES_APPLITOOLS__';
|
|
100
|
+
const global = window;
|
|
101
|
+
if (!global[APPLITOOLS_NAMESPACE] || !global[APPLITOOLS_NAMESPACE][resultId])
|
|
102
|
+
return [];
|
|
103
|
+
const elements = global[APPLITOOLS_NAMESPACE][resultId];
|
|
104
|
+
return elements;
|
|
105
|
+
});
|
|
106
|
+
function isDriver(t) {
|
|
107
|
+
return utils.types.instanceOf(t, 'TestController');
|
|
108
|
+
}
|
|
109
|
+
exports.isDriver = isDriver;
|
|
110
|
+
function isElement(element) {
|
|
111
|
+
if (!element)
|
|
112
|
+
return false;
|
|
113
|
+
return !!(element.addCustomMethods && element.find && element.parent);
|
|
114
|
+
}
|
|
115
|
+
exports.isElement = isElement;
|
|
116
|
+
function isSecondaryElement(element) {
|
|
117
|
+
if (!element)
|
|
118
|
+
return false;
|
|
119
|
+
return !!(element.nodeType && isElement(element.selector));
|
|
120
|
+
}
|
|
121
|
+
exports.isSecondaryElement = isSecondaryElement;
|
|
122
|
+
function isSelector(selector) {
|
|
123
|
+
if (!selector)
|
|
124
|
+
return false;
|
|
125
|
+
return Boolean(selector.addCustomMethods && selector.find && selector.parent);
|
|
126
|
+
}
|
|
127
|
+
exports.isSelector = isSelector;
|
|
128
|
+
function toElement(element) {
|
|
129
|
+
if (utils.types.isFunction(element.selector))
|
|
130
|
+
return element.selector;
|
|
131
|
+
return element;
|
|
132
|
+
}
|
|
133
|
+
exports.toElement = toElement;
|
|
134
|
+
function toSelector(selector) {
|
|
135
|
+
if (utils.types.has(selector, 'selector')) {
|
|
136
|
+
let current = selector;
|
|
137
|
+
let transformed = selector.type === 'xpath' ? XPathSelector(current.selector) : testcafe.Selector(current.selector);
|
|
138
|
+
while (current.child || current.shadow) {
|
|
139
|
+
if (current.child) {
|
|
140
|
+
current = utils.types.has(current.child, 'selector') ? current.child : { selector: current.child };
|
|
141
|
+
transformed = transformed.find(current.selector);
|
|
142
|
+
}
|
|
143
|
+
else if (current.shadow) {
|
|
144
|
+
current = utils.types.has(current.shadow, 'selector') ? current.shadow : { selector: current.shadow };
|
|
145
|
+
transformed = transformed.shadowRoot().find(current.selector);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return transformed;
|
|
149
|
+
}
|
|
150
|
+
return testcafe.Selector(selector);
|
|
151
|
+
}
|
|
152
|
+
exports.toSelector = toSelector;
|
|
153
|
+
function extractSelector(element) {
|
|
154
|
+
return utils.types.isFunction(element.selector) ? element.selector : element;
|
|
155
|
+
}
|
|
156
|
+
exports.extractSelector = extractSelector;
|
|
157
|
+
async function executeScript(t, script, arg) {
|
|
158
|
+
script = utils.types.isFunction(script) ? script.toString() : script;
|
|
159
|
+
const { result, resultId, elementsCount } = await scriptRunner.with({
|
|
160
|
+
boundTestRun: t,
|
|
161
|
+
dependencies: { input: { script, arg } },
|
|
162
|
+
})();
|
|
163
|
+
if (!result || !resultId)
|
|
164
|
+
return result;
|
|
165
|
+
const elements = elementsExtractor.with({
|
|
166
|
+
boundTestRun: t,
|
|
167
|
+
dependencies: { input: { resultId } },
|
|
168
|
+
});
|
|
169
|
+
return deserializeResult(result, Array.from({ length: elementsCount }, (_, index) => elements.nth(index)));
|
|
170
|
+
}
|
|
171
|
+
exports.executeScript = executeScript;
|
|
172
|
+
async function findElement(t, selector) {
|
|
173
|
+
const element = await selector.with({ boundTestRun: t })();
|
|
174
|
+
return element ? element.selector : null;
|
|
175
|
+
}
|
|
176
|
+
exports.findElement = findElement;
|
|
177
|
+
async function findElements(t, selector) {
|
|
178
|
+
const elements = selector.with({ boundTestRun: t });
|
|
179
|
+
return Array.from({ length: await elements.count }, (_, index) => elements.nth(index));
|
|
180
|
+
}
|
|
181
|
+
exports.findElements = findElements;
|
|
182
|
+
async function click(t, element) {
|
|
183
|
+
await t.click(element);
|
|
184
|
+
}
|
|
185
|
+
exports.click = click;
|
|
186
|
+
async function setElementText(t, element, text) {
|
|
187
|
+
await t.typeText(element, text);
|
|
188
|
+
}
|
|
189
|
+
exports.setElementText = setElementText;
|
|
190
|
+
async function hover(t, element) {
|
|
191
|
+
await t.hover(element);
|
|
192
|
+
}
|
|
193
|
+
exports.hover = hover;
|
|
194
|
+
async function mainContext(t) {
|
|
195
|
+
await t.switchToMainWindow();
|
|
196
|
+
return t;
|
|
197
|
+
}
|
|
198
|
+
exports.mainContext = mainContext;
|
|
199
|
+
async function childContext(t, element) {
|
|
200
|
+
await t.switchToIframe(element);
|
|
201
|
+
return t;
|
|
202
|
+
}
|
|
203
|
+
exports.childContext = childContext;
|
|
204
|
+
async function getDriverInfo(_t) {
|
|
205
|
+
return { features: { nestedSelectors: true } };
|
|
206
|
+
}
|
|
207
|
+
exports.getDriverInfo = getDriverInfo;
|
|
208
|
+
async function setViewportSize(t, size) {
|
|
209
|
+
await t.resizeWindow(size.width, size.height);
|
|
210
|
+
}
|
|
211
|
+
exports.setViewportSize = setViewportSize;
|
|
212
|
+
async function getTitle(t) {
|
|
213
|
+
try {
|
|
214
|
+
return await testcafe.Selector('title', { boundTestRun: t }).innerText;
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
return '';
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
exports.getTitle = getTitle;
|
|
221
|
+
async function getUrl(t) {
|
|
222
|
+
return testcafe.ClientFunction(() => document.location.href, { boundTestRun: t })();
|
|
223
|
+
}
|
|
224
|
+
exports.getUrl = getUrl;
|
|
225
|
+
async function visit(t, url) {
|
|
226
|
+
await t.navigateTo(url);
|
|
227
|
+
}
|
|
228
|
+
exports.visit = visit;
|
|
229
|
+
async function takeScreenshot(t) {
|
|
230
|
+
// NOTE:
|
|
231
|
+
// Since we are constrained to saving screenshots to disk, we place each screenshot in its own
|
|
232
|
+
// dot-folder which has a GUID prefix (e.g., .applitools-guide/screenshot.png).
|
|
233
|
+
// We then read the file from disk, return the buffer, and delete the folder.
|
|
234
|
+
const screenshotPath = await t.takeScreenshot({
|
|
235
|
+
// thumbnails: false,
|
|
236
|
+
path: `.applitools/${utils.general.guid()}.png`,
|
|
237
|
+
});
|
|
238
|
+
try {
|
|
239
|
+
return fs.readFileSync(screenshotPath);
|
|
240
|
+
}
|
|
241
|
+
finally {
|
|
242
|
+
fs.unlinkSync(screenshotPath);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
exports.takeScreenshot = takeScreenshot;
|
package/package.json
CHANGED
|
@@ -1,45 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/eyes-testcafe",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "Applitools Eyes SDK for Testcafe",
|
|
6
|
-
"homepage": "https://applitools.com",
|
|
7
|
-
"author": {
|
|
8
|
-
"name": "Applitools Team",
|
|
9
|
-
"email": "team@applitools.com"
|
|
10
|
-
},
|
|
11
|
-
"files": [
|
|
12
|
-
"dist",
|
|
13
|
-
"lib",
|
|
14
|
-
"index.js"
|
|
15
|
-
],
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git://github.com/applitools/eyes.sdk.javascript1.git"
|
|
19
|
-
},
|
|
20
|
-
"bugs": {
|
|
21
|
-
"url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
|
|
22
|
-
},
|
|
23
|
-
"directories": {
|
|
24
|
-
"lib": "./lib",
|
|
25
|
-
"dist": "./dist"
|
|
26
|
-
},
|
|
27
|
-
"main": "./index.js",
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"@applitools/dom-utils": "^4.7.4",
|
|
30
|
-
"@applitools/eyes-common": "^3.18.0",
|
|
31
|
-
"@applitools/eyes-sdk-core": "^6.0.3",
|
|
32
|
-
"@applitools/functional-commons": "^1.5.4",
|
|
33
|
-
"@applitools/visual-grid-client": "^13.5.8",
|
|
34
|
-
"rimraf": "^3.0.0"
|
|
35
|
-
},
|
|
36
|
-
"peerDependencies": {
|
|
37
|
-
"testcafe": "^1.5.0"
|
|
38
|
-
},
|
|
39
|
-
"license": "SEE LICENSE FILE",
|
|
40
|
-
"engines": {
|
|
41
|
-
"node": ">=10.13.0"
|
|
42
|
-
},
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Applitools Eyes SDK for TestCafe",
|
|
43
5
|
"keywords": [
|
|
44
6
|
"eyes-testcafe",
|
|
45
7
|
"eyes-rendering",
|
|
@@ -53,44 +15,78 @@
|
|
|
53
15
|
"tests",
|
|
54
16
|
"testcafe"
|
|
55
17
|
],
|
|
18
|
+
"homepage": "https://applitools.com",
|
|
19
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
20
|
+
"author": {
|
|
21
|
+
"name": "Applitools Team",
|
|
22
|
+
"email": "team@applitools.com"
|
|
23
|
+
},
|
|
24
|
+
"main": "./dist/index-legacy.js",
|
|
25
|
+
"types": "./types/index-legacy.d.ts",
|
|
26
|
+
"typesVersions": {
|
|
27
|
+
"*": {
|
|
28
|
+
"dist": [
|
|
29
|
+
"./types/index.d.ts"
|
|
30
|
+
],
|
|
31
|
+
"next": [
|
|
32
|
+
"./types/index.d.ts"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./types/index-legacy.d.ts",
|
|
39
|
+
"default": "./dist/index-legacy.js"
|
|
40
|
+
},
|
|
41
|
+
"./dist/*": {
|
|
42
|
+
"types": "./types/*.d.ts",
|
|
43
|
+
"default": "./dist/*.js"
|
|
44
|
+
},
|
|
45
|
+
"./next": {
|
|
46
|
+
"types": "./types/index.d.ts",
|
|
47
|
+
"default": "./dist/index.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"dist",
|
|
52
|
+
"types"
|
|
53
|
+
],
|
|
56
54
|
"scripts": {
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"test
|
|
61
|
-
"test:
|
|
62
|
-
"test:
|
|
63
|
-
"test:
|
|
64
|
-
"test:
|
|
65
|
-
"
|
|
55
|
+
"lint": "run --top-level eslint '**/*.ts' '**/*.js'",
|
|
56
|
+
"build": "run --top-level tspc --project ./tsconfig.build.json",
|
|
57
|
+
"generate:tests": "NODE_OPTIONS='--experimental-import-meta-resolve --experimental-loader=@applitools/generic/dist/code-loader.js' generic ./test/generic/config.mjs",
|
|
58
|
+
"test": "run test:unit && run test:it && run test:coverage",
|
|
59
|
+
"test:unit": "run --top-level mocha './test/unit/*.spec.ts'",
|
|
60
|
+
"test:it": "run test:it:chrome",
|
|
61
|
+
"test:it:chrome": "testcafe chrome:headless './test/it/*.spec.ts'",
|
|
62
|
+
"test:it:firefox": "testcafe firefox:headless './test/it/*.spec.ts'",
|
|
63
|
+
"test:coverage": "APPLITOOLS_BATCH_NAME='JS Coverage Tests: eyes-testcafe' APPLITOOLS_BATCH_ID=$(uuidgen) testcafe chrome:headless './test/generated-coverage/*.spec.js' --concurrency 10",
|
|
64
|
+
"perf": "testcafe chrome:headless test/perf/perf.spec.js",
|
|
65
|
+
"perf:full": "run perf && run perf -c 5",
|
|
66
|
+
"perf:lite": "testcafe chrome:headless test/perf/perf-lite.spec.js",
|
|
67
|
+
"perf:lite:full": "run perf:lite && run perf:lite -c 5",
|
|
68
|
+
"up:framework": "yarn add --dev --caret testcafe${APPLITOOLS_FRAMEWORK_VERSION:+@$APPLITOOLS_FRAMEWORK_VERSION}"
|
|
69
|
+
},
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"@applitools/driver": "1.14.3",
|
|
72
|
+
"@applitools/eyes": "1.10.0",
|
|
73
|
+
"@applitools/utils": "1.6.1"
|
|
66
74
|
},
|
|
67
75
|
"devDependencies": {
|
|
68
|
-
"@applitools/
|
|
69
|
-
"@applitools/
|
|
70
|
-
"@
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
"mocha": "^6.2.2",
|
|
84
|
-
"rollup": "^1.27.9",
|
|
85
|
-
"rollup-plugin-babel": "^4.3.3",
|
|
86
|
-
"rollup-plugin-commonjs": "^10.1.0",
|
|
87
|
-
"rollup-plugin-node-globals": "^1.4.0",
|
|
88
|
-
"rollup-plugin-node-resolve": "^5.2.0",
|
|
89
|
-
"rollup-plugin-polyfill": "^3.0.0",
|
|
90
|
-
"testcafe": "^1.5.0",
|
|
91
|
-
"testcafe-browser-provider-browserstack": "^1.10.1",
|
|
92
|
-
"ua-parser-js": "^0.7.20",
|
|
93
|
-
"url-polyfill": "^1.1.7",
|
|
94
|
-
"whatwg-fetch": "^3.0.0"
|
|
76
|
+
"@applitools/api-extractor": "^1.2.22",
|
|
77
|
+
"@applitools/bongo": "^5.6.1",
|
|
78
|
+
"@applitools/generic": "^3.3.10",
|
|
79
|
+
"@applitools/test-server": "^1.2.2",
|
|
80
|
+
"@applitools/test-utils": "^1.5.17",
|
|
81
|
+
"testcafe": "1"
|
|
82
|
+
},
|
|
83
|
+
"peerDependencies": {
|
|
84
|
+
"testcafe": ">=1.7.1"
|
|
85
|
+
},
|
|
86
|
+
"engines": {
|
|
87
|
+
"node": ">=12.13.0"
|
|
88
|
+
},
|
|
89
|
+
"publishConfig": {
|
|
90
|
+
"access": "public"
|
|
95
91
|
}
|
|
96
|
-
}
|
|
92
|
+
}
|