@testim/testim-cli 3.263.0 → 3.265.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/commons/featureFlags.js +1 -3
- package/commons/testimDesiredCapabilitiesBuilder.js +24 -67
- package/npm-shrinkwrap.json +818 -1206
- package/package.json +2 -3
- package/player/WebdriverioWebDriverApi.js +15 -26
- package/player/stepActions/baseJsStepAction.js +15 -38
- package/player/stepActions/locateStepAction.js +1 -18
- package/player/stepActions/mouseStepAction.js +9 -20
- package/player/stepActions/pixelValidationStepAction.js +6 -4
- package/player/stepActions/scripts/runCode.js +2 -2
- package/player/stepActions/scripts/wheel.js +8 -23
- package/player/stepActions/textStepAction.js +2 -6
- package/player/stepActions/wheelStepAction.js +2 -6
- package/player/utils/eyeSdkService.js +7 -15
- package/player/webdriver.js +13 -35
- package/runOptions.d.ts +1 -1
- package/runOptions.js +1 -9
- package/runners/runnerUtils.js +1 -1
- package/utils/promiseUtils.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testim/testim-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.265.0",
|
|
4
4
|
"description": "Command line interface for running Testing on your CI",
|
|
5
5
|
"author": "Oren Rubin",
|
|
6
6
|
"contributors": [{
|
|
@@ -43,8 +43,7 @@
|
|
|
43
43
|
"multer": "1.4.4"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@applitools/eyes-sdk-core": "13.
|
|
47
|
-
"@applitools/visual-grid-client": "15.12.34",
|
|
46
|
+
"@applitools/eyes-sdk-core": "13.11.21",
|
|
48
47
|
"@testim/coralogix-logger": "1.1.27-beta.1",
|
|
49
48
|
"@testim/webdriverio": "0.0.5",
|
|
50
49
|
"abort-controller": "3.0.0",
|
|
@@ -17,12 +17,9 @@ Queue.configure(Promise);
|
|
|
17
17
|
const perf = require('../commons/performance-logger');
|
|
18
18
|
|
|
19
19
|
const getViewportSizeHelper = function () {
|
|
20
|
-
// this runs on the AUT, should be compatible with old browsers
|
|
21
|
-
// eslint-disable-next-line no-var
|
|
22
|
-
var pixelRatio = (/(MSIE)|(Trident)/.test(navigator.userAgent)) ? (window.screen.systemXDPI / window.screen.deviceXDPI) : 1;
|
|
23
20
|
return {
|
|
24
|
-
screenWidth: Math.floor(
|
|
25
|
-
screenHeight: Math.floor(
|
|
21
|
+
screenWidth: Math.floor(window.innerWidth || 0),
|
|
22
|
+
screenHeight: Math.floor(window.innerHeight || 0),
|
|
26
23
|
};
|
|
27
24
|
};
|
|
28
25
|
|
|
@@ -49,7 +46,7 @@ class WebdriverioWebDriverApi {
|
|
|
49
46
|
|
|
50
47
|
initQueueRequests() {
|
|
51
48
|
let maxConcurrent = Infinity;
|
|
52
|
-
if (this.
|
|
49
|
+
if (this.isAndroid()) {
|
|
53
50
|
maxConcurrent = 1;
|
|
54
51
|
}
|
|
55
52
|
if (typeof config.REQUESTS_QUEUE_SIZE !== 'undefined') {
|
|
@@ -90,7 +87,7 @@ class WebdriverioWebDriverApi {
|
|
|
90
87
|
}
|
|
91
88
|
|
|
92
89
|
getSessionId() {
|
|
93
|
-
return this.client
|
|
90
|
+
return this.client?.requestHandler?.sessionID;
|
|
94
91
|
}
|
|
95
92
|
|
|
96
93
|
isChrome() {
|
|
@@ -109,18 +106,10 @@ class WebdriverioWebDriverApi {
|
|
|
109
106
|
return this.client.desiredCapabilities.browserName === 'safari' || this.client.desiredCapabilities.browserName === 'safari technology preview';
|
|
110
107
|
}
|
|
111
108
|
|
|
112
|
-
isIE() {
|
|
113
|
-
return this.client.desiredCapabilities.browserName === 'internet explorer';
|
|
114
|
-
}
|
|
115
|
-
|
|
116
109
|
isAndroid() {
|
|
117
110
|
return this.client.desiredCapabilities.platformName === 'Android';
|
|
118
111
|
}
|
|
119
112
|
|
|
120
|
-
isEdge() {
|
|
121
|
-
return this.client.desiredCapabilities.browserName === 'MicrosoftEdge' && this.client.desiredCapabilities._isOldEdge;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
113
|
isEdgeChromium() {
|
|
125
114
|
return this.client.desiredCapabilities.browserName === 'MicrosoftEdge' && !this.client.desiredCapabilities._isOldEdge;
|
|
126
115
|
}
|
|
@@ -169,7 +158,7 @@ class WebdriverioWebDriverApi {
|
|
|
169
158
|
return newEndpoint();
|
|
170
159
|
}
|
|
171
160
|
|
|
172
|
-
|
|
161
|
+
throw err;
|
|
173
162
|
});
|
|
174
163
|
});
|
|
175
164
|
}
|
|
@@ -220,7 +209,7 @@ class WebdriverioWebDriverApi {
|
|
|
220
209
|
return newEndpoint();
|
|
221
210
|
}
|
|
222
211
|
|
|
223
|
-
|
|
212
|
+
throw err;
|
|
224
213
|
});
|
|
225
214
|
});
|
|
226
215
|
}
|
|
@@ -275,7 +264,7 @@ class WebdriverioWebDriverApi {
|
|
|
275
264
|
return newEndpoint();
|
|
276
265
|
}
|
|
277
266
|
|
|
278
|
-
|
|
267
|
+
throw err;
|
|
279
268
|
});
|
|
280
269
|
});
|
|
281
270
|
}
|
|
@@ -299,7 +288,7 @@ class WebdriverioWebDriverApi {
|
|
|
299
288
|
return newEndpoint();
|
|
300
289
|
}
|
|
301
290
|
|
|
302
|
-
|
|
291
|
+
throw err;
|
|
303
292
|
});
|
|
304
293
|
});
|
|
305
294
|
}
|
|
@@ -337,7 +326,7 @@ class WebdriverioWebDriverApi {
|
|
|
337
326
|
this.w3cRequests.timeouts = true;
|
|
338
327
|
return newEndpoint();
|
|
339
328
|
}
|
|
340
|
-
|
|
329
|
+
throw err;
|
|
341
330
|
});
|
|
342
331
|
});
|
|
343
332
|
}
|
|
@@ -373,7 +362,7 @@ class WebdriverioWebDriverApi {
|
|
|
373
362
|
}
|
|
374
363
|
|
|
375
364
|
keys(value) {
|
|
376
|
-
const checkUnicode =
|
|
365
|
+
const checkUnicode = _value => (UNICODE_CHARACTERS.hasOwnProperty(_value) ? [UNICODE_CHARACTERS[_value]] : _value.split(''));
|
|
377
366
|
|
|
378
367
|
let key = [];
|
|
379
368
|
|
|
@@ -392,8 +381,8 @@ class WebdriverioWebDriverApi {
|
|
|
392
381
|
|
|
393
382
|
const oldEndpoint = () => this.client.requestHandler.create('/session/:sessionId/keys', { value: key });
|
|
394
383
|
const newEndpoint = () => {
|
|
395
|
-
const keyDownActions = key.map((
|
|
396
|
-
const keyUpActions = key.map((
|
|
384
|
+
const keyDownActions = key.map((_value) => ({ type: 'keyDown', value: _value }));
|
|
385
|
+
const keyUpActions = key.map((_value) => ({ type: 'keyUp', value: _value }));
|
|
397
386
|
|
|
398
387
|
return this.actions([{
|
|
399
388
|
type: 'key',
|
|
@@ -415,7 +404,7 @@ class WebdriverioWebDriverApi {
|
|
|
415
404
|
return newEndpoint();
|
|
416
405
|
}
|
|
417
406
|
|
|
418
|
-
|
|
407
|
+
throw err;
|
|
419
408
|
}));
|
|
420
409
|
}
|
|
421
410
|
|
|
@@ -537,7 +526,7 @@ class WebdriverioWebDriverApi {
|
|
|
537
526
|
// we make sure to use its absolute value.
|
|
538
527
|
data = {
|
|
539
528
|
width: Math.abs(size.width),
|
|
540
|
-
height: Math.abs(
|
|
529
|
+
height: Math.abs(size.height),
|
|
541
530
|
};
|
|
542
531
|
}
|
|
543
532
|
|
|
@@ -568,7 +557,7 @@ class WebdriverioWebDriverApi {
|
|
|
568
557
|
return newEndpoint();
|
|
569
558
|
}
|
|
570
559
|
|
|
571
|
-
|
|
560
|
+
throw err;
|
|
572
561
|
});
|
|
573
562
|
});
|
|
574
563
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable prefer-template */
|
|
2
|
-
|
|
3
1
|
'use strict';
|
|
4
2
|
|
|
5
3
|
const Promise = require('bluebird');
|
|
@@ -17,15 +15,6 @@ const logger = require('../../commons/logger').getLogger('base-js-step-action');
|
|
|
17
15
|
const _ = require('lodash');
|
|
18
16
|
const utils = require('../../utils');
|
|
19
17
|
|
|
20
|
-
function constructWithArguments(constructor, args) {
|
|
21
|
-
function F() {
|
|
22
|
-
return constructor.apply(this, args);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
F.prototype = constructor.prototype;
|
|
26
|
-
return new F();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
18
|
class BaseJsStepAction extends StepAction {
|
|
30
19
|
isExceedingMaxResultSize(data, context) {
|
|
31
20
|
try {
|
|
@@ -45,16 +34,16 @@ class BaseJsStepAction extends StepAction {
|
|
|
45
34
|
}
|
|
46
35
|
|
|
47
36
|
executeGetStatus(transactionId) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const sessionItem = 'data-testim-' + transactionId;
|
|
37
|
+
return this.driver.executeJS(_transactionId => {
|
|
38
|
+
/* eslint-disable no-undef */
|
|
39
|
+
const sessionItem = `data-testim-${_transactionId}`;
|
|
52
40
|
try {
|
|
53
41
|
return window.sessionStorage.getItem(sessionItem);
|
|
54
42
|
} catch (err) {
|
|
55
|
-
if (
|
|
56
|
-
err.message.
|
|
57
|
-
err.message.
|
|
43
|
+
if (
|
|
44
|
+
err.message.includes('sessionStorage') || // Chrome + Firefox
|
|
45
|
+
err.message.includes('The operation is insecure') // Safari
|
|
46
|
+
) {
|
|
58
47
|
const storage = document.head.querySelector('#testim-storage-backup');
|
|
59
48
|
if (!storage) {
|
|
60
49
|
return '{}';
|
|
@@ -63,8 +52,8 @@ class BaseJsStepAction extends StepAction {
|
|
|
63
52
|
}
|
|
64
53
|
throw err;
|
|
65
54
|
}
|
|
55
|
+
/* eslint-enable no-undef */
|
|
66
56
|
}, transactionId);
|
|
67
|
-
/* eslint-enable prefer-arrow-callback, no-undef, unicorn/prefer-includes, no-shadow */
|
|
68
57
|
}
|
|
69
58
|
|
|
70
59
|
constructJSFunParams(eventData) {
|
|
@@ -146,7 +135,7 @@ class BaseJsStepAction extends StepAction {
|
|
|
146
135
|
let funcToRunString = 'undefined';
|
|
147
136
|
if (useExperimentalPreCompilation) {
|
|
148
137
|
const paramNames = rawParams.function.params.slice(0, -1);
|
|
149
|
-
funcToRunString =
|
|
138
|
+
funcToRunString = experimentalAsyncCustomCode ? `async function(${paramNames.join(',')}) {
|
|
150
139
|
${eventMessage.code}
|
|
151
140
|
};` : `function(${paramNames.join(',')}) {
|
|
152
141
|
${eventMessage.code}
|
|
@@ -158,16 +147,15 @@ class BaseJsStepAction extends StepAction {
|
|
|
158
147
|
const runCode = `
|
|
159
148
|
${hasLocateParams ? `var getLocatedElement = ${codeSnippets.getLocatedElementCode};` : ';'}
|
|
160
149
|
var runCode = ${runCodeScript.toString()};
|
|
161
|
-
var eventData =
|
|
150
|
+
var eventData = arguments[0];
|
|
162
151
|
var funcToRun = ${funcToRunString};
|
|
163
152
|
return runCode.call(null, eventData, funcToRun);
|
|
164
153
|
`;
|
|
165
|
-
const params = this.driver.isEdge() ? JSON.stringify(rawParams) : rawParams;
|
|
166
154
|
if (!useExperimentalPreCompilation) {
|
|
167
|
-
return this.driver.executeJS(runCode,
|
|
155
|
+
return this.driver.executeJS(runCode, rawParams);
|
|
168
156
|
}
|
|
169
157
|
|
|
170
|
-
return this.driver.executeJS(runCode,
|
|
158
|
+
return this.driver.executeJS(runCode, rawParams).catch(err => this.handleExecutionError(err));
|
|
171
159
|
}
|
|
172
160
|
|
|
173
161
|
codeExecDone(resp) {
|
|
@@ -276,20 +264,9 @@ class BaseJsStepAction extends StepAction {
|
|
|
276
264
|
err.seleniumStack.orgStatusMessage;
|
|
277
265
|
|
|
278
266
|
if (canExtractError) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
throw new Error(reason);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// IE has unhelpful messages
|
|
286
|
-
try {
|
|
287
|
-
constructWithArguments(Function, rawParams.function.params.concat([eventMessage.code]));
|
|
288
|
-
} catch (err) {
|
|
289
|
-
if (err instanceof SyntaxError) {
|
|
290
|
-
throw new Error(err.message);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
267
|
+
const endOfMessage = err.seleniumStack.orgStatusMessage.indexOf('\nBuild info');
|
|
268
|
+
const reason = err.seleniumStack.orgStatusMessage.slice(0, endOfMessage === -1 ? undefined : endOfMessage);
|
|
269
|
+
throw new Error(reason);
|
|
293
270
|
}
|
|
294
271
|
|
|
295
272
|
throw err;
|
|
@@ -52,8 +52,7 @@ function createUtils(driver) {
|
|
|
52
52
|
window.close();
|
|
53
53
|
}, 1000 * 60);
|
|
54
54
|
}
|
|
55
|
-
window.document
|
|
56
|
-
return window.document;
|
|
55
|
+
return Object.assign(window.document, { TESTIM_URL: url });
|
|
57
56
|
},
|
|
58
57
|
|
|
59
58
|
shouldUseNativeVisibilityCheck(locateStep, driver, visibilityUtils, positionUtils) {
|
|
@@ -72,27 +71,11 @@ function createUtils(driver) {
|
|
|
72
71
|
if (driver.isSafari()) {
|
|
73
72
|
return featureFlags.flags.useSafariWebdriverVisibilityChecks.isEnabled();
|
|
74
73
|
}
|
|
75
|
-
if (driver.isIE()) {
|
|
76
|
-
return featureFlags.flags.useIEWebdriverVisibilityChecks.isEnabled();
|
|
77
|
-
}
|
|
78
74
|
return true;
|
|
79
75
|
},
|
|
80
76
|
|
|
81
77
|
/** @type {typeof import('clickim/src/background/stepActions/locateStepAction').LocateStepAction['isVisible']} */
|
|
82
78
|
async isVisible(target, targetElement, rect, locateStep, frameHandler, allOffsets, dom) {
|
|
83
|
-
const skipVisibilityCheck = featureFlags.flags.disableEdgeVisibilityChecks.isEnabled() && driver.isEdge();
|
|
84
|
-
|
|
85
|
-
if (skipVisibilityCheck) {
|
|
86
|
-
logger.info('bypassed visibility check because of feature flag');
|
|
87
|
-
target.visibilityCheckSkipped = skipVisibilityCheck;
|
|
88
|
-
try {
|
|
89
|
-
await driver.isVisible(target.seleniumElement);
|
|
90
|
-
} catch {
|
|
91
|
-
/* ignored */
|
|
92
|
-
}
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
79
|
const useNativeVisibilityCheck = this.shouldUseNativeVisibilityCheck(locateStep, driver, visibilityUtils, positionUtils);
|
|
97
80
|
if (useNativeVisibilityCheck) {
|
|
98
81
|
return driver.isVisible(target.seleniumElement);
|
|
@@ -48,17 +48,14 @@ class MouseStepAction extends StepAction {
|
|
|
48
48
|
var getLocatedElement = ${codeSnippets.getLocatedElementCode};
|
|
49
49
|
var dispatchFocus = ${dispatchFocus.toString()};
|
|
50
50
|
var doClick = ${doClickScript.toString()};
|
|
51
|
-
var eventData =
|
|
51
|
+
var eventData = arguments[0];
|
|
52
52
|
var done = arguments[1];
|
|
53
53
|
return doClick.call(null, eventData, done);
|
|
54
54
|
`;
|
|
55
55
|
|
|
56
|
-
// hack for Edge (17/18) which does not accept properties with negative (throws Unknown Error)
|
|
57
|
-
// values between 0 and -1 -_-.
|
|
58
|
-
const eventParam = this.driver.isEdge() ? JSON.stringify(eventMessage) : eventMessage;
|
|
59
56
|
|
|
60
57
|
try {
|
|
61
|
-
const result = await this.driver.executeCodeAsync(doClickCode, timeout,
|
|
58
|
+
const result = await this.driver.executeCodeAsync(doClickCode, timeout, eventMessage);
|
|
62
59
|
if (result.value?.success) {
|
|
63
60
|
return { success: true };
|
|
64
61
|
}
|
|
@@ -192,7 +189,7 @@ class MouseStepAction extends StepAction {
|
|
|
192
189
|
};
|
|
193
190
|
// will skip left click and double click on Edge.
|
|
194
191
|
const skipFileInputClick =
|
|
195
|
-
|
|
192
|
+
featureFlagService.flags.skipFileInputClicks.isEnabled() &&
|
|
196
193
|
target.tagName === 'INPUT' &&
|
|
197
194
|
(target.elementSymbol.includes('type="file"') ||
|
|
198
195
|
target.elementSymbol.includes('type=\'file\'') ||
|
|
@@ -219,8 +216,7 @@ class MouseStepAction extends StepAction {
|
|
|
219
216
|
if (this.step.toElement) {
|
|
220
217
|
const destTarget = this.context.data.toElement;
|
|
221
218
|
if (this.step.isHTML5Drag) {
|
|
222
|
-
|
|
223
|
-
if (!isIE && featureFlagService.flags.usePortedHtml5DragDrop.isEnabled()) {
|
|
219
|
+
if (featureFlagService.flags.usePortedHtml5DragDrop.isEnabled()) {
|
|
224
220
|
const events = this.generateHTML5DragEventSequence();
|
|
225
221
|
const timeout = this.context.data.timeToPlayStep + 3000;
|
|
226
222
|
const contextTarget = this.context.data[this.step.targetId || 'targetId'];
|
|
@@ -243,32 +239,25 @@ class MouseStepAction extends StepAction {
|
|
|
243
239
|
locatedElement: contextTarget.locatedElement,
|
|
244
240
|
isRoot: contextTarget.isRoot,
|
|
245
241
|
};
|
|
246
|
-
// hack for Edge (17/18) which does not accept properties with negative (throws Unknown Error)
|
|
247
|
-
// values between 0 and -1 -_-.
|
|
248
|
-
const eventParam = this.driver.isEdge() ? JSON.stringify(eventMessage) : eventMessage;
|
|
249
242
|
const html5DNDCode = `
|
|
250
243
|
var getLocatedElement = ${codeSnippets.getLocatedElementCode};
|
|
251
244
|
var dnd = ${html5dndActionV2.toString()};
|
|
252
|
-
var eventData =
|
|
245
|
+
var eventData = arguments[0];
|
|
253
246
|
var done = arguments[1];
|
|
254
247
|
return dnd.call(null, eventData, done);
|
|
255
248
|
`;
|
|
256
|
-
return this.driver.executeCodeAsync(html5DNDCode, timeout,
|
|
249
|
+
return this.driver.executeCodeAsync(html5DNDCode, timeout, eventMessage);
|
|
257
250
|
}
|
|
258
251
|
|
|
259
252
|
const html5DNDCode = `
|
|
260
253
|
var getLocatedElement = ${codeSnippets.getLocatedElementCode};
|
|
261
254
|
var dnd = ${html5dndAction.toString()};
|
|
262
|
-
var eventData =
|
|
255
|
+
var eventData = arguments[0];
|
|
263
256
|
return dnd.call(null, eventData);
|
|
264
257
|
`;
|
|
265
258
|
|
|
266
259
|
const eventMessage = { fromLocatedElement: locatedElement, toLocatedElement: destTarget.locatedElement };
|
|
267
|
-
|
|
268
|
-
// hack for Edge (17/18) which does not accept properties with negative (throws Unknown Error)
|
|
269
|
-
// values between 0 and -1 -_-.
|
|
270
|
-
const eventParam = this.driver.isEdge() ? JSON.stringify(eventMessage) : eventMessage;
|
|
271
|
-
return this.driver.executeJS(html5DNDCode, eventParam);
|
|
260
|
+
return this.driver.executeJS(html5DNDCode, eventMessage);
|
|
272
261
|
}
|
|
273
262
|
|
|
274
263
|
const rectsAndOffsets = this.getDnDRectsAndOffsets(target, destTarget, this.step.element.clickOffset, this.step.toElement.clickOffset);
|
|
@@ -279,7 +268,7 @@ class MouseStepAction extends StepAction {
|
|
|
279
268
|
// This is the old way, which uses selenium action (AKA "native" drag).
|
|
280
269
|
// return this.driver.drag(seleniumElement, rectWithoutFrameOffset, xOffset, yOffset, this.step.events);
|
|
281
270
|
}
|
|
282
|
-
const useRightClickJS =
|
|
271
|
+
const useRightClickJS = this.driver.isSafari() && this.step.button === 2;
|
|
283
272
|
const forceNativeEvent = this.driver.isSafari() && target.tagName === 'SELECT';
|
|
284
273
|
|
|
285
274
|
if (this.driver.isSafari() && forceNativeEvent) {
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
const StepAction = require('./stepAction');
|
|
5
5
|
const { eyeSdkService } = require('../utils/eyeSdkService');
|
|
6
|
-
const
|
|
6
|
+
const { getLogger } = require('../../commons/logger');
|
|
7
|
+
|
|
8
|
+
const logger = getLogger('pixel-validation-step-action');
|
|
7
9
|
|
|
8
10
|
class PixelValidationStepAction extends StepAction {
|
|
9
11
|
async performAction() {
|
|
10
|
-
const { shouldUseVisualGrid, applitoolsSdkConfig: config, testResultId } = this.context;
|
|
12
|
+
const { shouldUseVisualGrid, applitoolsSdkConfig: config, applitoolsSdkLogger, testResultId } = this.context;
|
|
11
13
|
this.runContext = this.context.getRunContext(undefined);
|
|
12
14
|
const finalParams = this.runContext.incomingParams?.final || {};
|
|
13
15
|
const batchId = config.batch?.id || testResultId;
|
|
@@ -15,10 +17,10 @@ class PixelValidationStepAction extends StepAction {
|
|
|
15
17
|
const targetElementData = this.getTarget() || {};
|
|
16
18
|
let result;
|
|
17
19
|
try {
|
|
18
|
-
const openedEye = await eyeManager.openEyes({ driver: this.driver.client, config });
|
|
20
|
+
const openedEye = await eyeManager.openEyes({ driver: this.driver.client, config, logger: applitoolsSdkLogger });
|
|
19
21
|
const region = (this.step.action === 'element' && targetElementData.seleniumElement) || undefined;
|
|
20
22
|
const settings = { region, fully: this.step.action === 'stitched' };
|
|
21
|
-
if (
|
|
23
|
+
if (_.isPlainObject(finalParams.applitoolsStepSettings)) {
|
|
22
24
|
Object.assign(settings, finalParams.applitoolsStepSettings);
|
|
23
25
|
logger.info('Applitools SDK step executed with applitoolsStepSettings parameter', { applitoolsStepSettings: finalParams.applitoolsStepSettings });
|
|
24
26
|
}
|
|
@@ -32,9 +32,9 @@ const runCode = function (eventData, preCompiledCode) {
|
|
|
32
32
|
const isQuotaExceededError = err.message.toLowerCase().indexOf('quota') > -1;
|
|
33
33
|
const isNativeFunctionError = err.message === nativeFuncErrMsg;
|
|
34
34
|
|
|
35
|
-
if (
|
|
35
|
+
if (
|
|
36
|
+
err.message.indexOf('sessionStorage') > -1 || // Chrome + Firefox
|
|
36
37
|
err.message.indexOf('The operation is insecure') > -1 || // Safari
|
|
37
|
-
err.message.indexOf('SecurityError') > -1 || // Edge
|
|
38
38
|
isQuotaExceededError ||
|
|
39
39
|
isNativeFunctionError
|
|
40
40
|
) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
2
3
|
/*global WheelEvent */
|
|
3
4
|
var wheel = function (eventData, done) {
|
|
4
5
|
var MAX_WHEEL_EVENT_TIMEOUT = 200;
|
|
@@ -9,30 +10,14 @@ var wheel = function (eventData, done) {
|
|
|
9
10
|
}
|
|
10
11
|
var pointerPosition = userEvent.pointerPosition || {};
|
|
11
12
|
var rect = element.getBoundingClientRect();
|
|
12
|
-
var clientX = pointerPosition.originX && isWithinBounds(rect.left, rect.left + rect.width, pointerPosition.originX) ? pointerPosition.originX : rect.left + (rect.width/2);
|
|
13
|
-
var clientY = pointerPosition.originY && isWithinBounds(rect.top,
|
|
14
|
-
return {x: clientX, y: clientY};
|
|
13
|
+
var clientX = pointerPosition.originX && isWithinBounds(rect.left, rect.left + rect.width, pointerPosition.originX) ? pointerPosition.originX : rect.left + (rect.width / 2);
|
|
14
|
+
var clientY = pointerPosition.originY && isWithinBounds(rect.top, rect.top + rect.height, pointerPosition.originY) ? pointerPosition.originY : rect.top + (rect.height / 2);
|
|
15
|
+
return { x: clientX, y: clientY };
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
function getWheelEvent(userEvent, eventData, element) {
|
|
18
|
-
var isIE = (navigator.appVersion.indexOf('Trident/') > 0) || (navigator.userAgent.indexOf('MSIE') !== -1);
|
|
19
|
-
return isIE ?
|
|
20
|
-
getWheelEventIE(userEvent, eventData, element) :
|
|
21
|
-
getWheelEventNonIE(userEvent, eventData, element);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function getWheelEventIE(userEvent, eventData, element) {
|
|
25
|
-
var pos = getEventPosition(userEvent, element);
|
|
26
|
-
var modifiers = (eventData && eventData.modifiers) || {};
|
|
27
|
-
var modifiersString = Object.keys(modifiers).join(" ");
|
|
28
|
-
var event = document.createEvent('WheelEvent');
|
|
29
|
-
event.initWheelEvent('wheel', true, true, window, 0, 0, 0, pos.x, pos.y, 0, null, modifiersString, userEvent.deltaX, userEvent.deltaY, userEvent.deltaZ, userEvent.deltaMode);
|
|
30
|
-
return event;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function getWheelEventNonIE(userEvent, eventData, element) {
|
|
34
19
|
var pos = getEventPosition(userEvent, element);
|
|
35
|
-
var modifiers =
|
|
20
|
+
var modifiers = eventData?.modifiers || {};
|
|
36
21
|
var dict = {
|
|
37
22
|
deltaX: userEvent.deltaX,
|
|
38
23
|
deltaY: userEvent.deltaY,
|
|
@@ -45,14 +30,14 @@ var wheel = function (eventData, done) {
|
|
|
45
30
|
ctrl: Boolean(modifiers.ctrl),
|
|
46
31
|
alt: Boolean(modifiers.alt),
|
|
47
32
|
shift: Boolean(modifiers.shift),
|
|
48
|
-
meta: Boolean(modifiers.meta)
|
|
33
|
+
meta: Boolean(modifiers.meta),
|
|
49
34
|
};
|
|
50
35
|
return new WheelEvent('wheel', dict);
|
|
51
36
|
}
|
|
52
37
|
|
|
53
38
|
function executeEvents(events, element) {
|
|
54
39
|
if (events.length === 0) {
|
|
55
|
-
return done({state:
|
|
40
|
+
return done({ state: 'success' });
|
|
56
41
|
}
|
|
57
42
|
if (!element) {
|
|
58
43
|
throw new Error('element not found');
|
|
@@ -50,16 +50,12 @@ class TextStepAction extends StepAction {
|
|
|
50
50
|
var getLocatedElement = ${codeSnippets.getLocatedElementCode};
|
|
51
51
|
var dispatchFocus = ${dispatchFocus};
|
|
52
52
|
var setText = ${setTextScript.toString()};
|
|
53
|
-
var eventData =
|
|
53
|
+
var eventData = arguments[0];
|
|
54
54
|
var done = arguments[1];
|
|
55
55
|
return setText.call(null, eventData, done);
|
|
56
56
|
`;
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
// values between 0 and -1 -_-.
|
|
60
|
-
const eventParam = this.driver.isEdge() ? JSON.stringify(eventMessage) : eventMessage;
|
|
61
|
-
|
|
62
|
-
const result = await this.driver.executeCodeAsync(setTextCode, timeout, eventParam);
|
|
58
|
+
const result = await this.driver.executeCodeAsync(setTextCode, timeout, eventMessage);
|
|
63
59
|
return { success: Boolean(result.value?.success) };
|
|
64
60
|
}
|
|
65
61
|
|
|
@@ -28,16 +28,12 @@ class WheelStepAction extends StepAction {
|
|
|
28
28
|
const wheelCode = `
|
|
29
29
|
var getLocatedElement = ${codeSnippets.getLocatedElementCode};
|
|
30
30
|
var wheel = ${wheelScript.toString()};
|
|
31
|
-
var eventData =
|
|
31
|
+
var eventData = arguments[0];
|
|
32
32
|
var done = arguments[1];
|
|
33
33
|
return wheel.call(null, eventData, done);
|
|
34
34
|
`;
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
// values between 0 and -1 -_-.
|
|
38
|
-
const eventParam = this.driver.isEdge() ? JSON.stringify(eventMessage) : eventMessage;
|
|
39
|
-
|
|
40
|
-
const result = await this.driver.executeCodeAsync(wheelCode, timeout, eventParam);
|
|
36
|
+
const result = await this.driver.executeCodeAsync(wheelCode, timeout, eventMessage);
|
|
41
37
|
return { success: result.value?.state === 'success' };
|
|
42
38
|
}
|
|
43
39
|
}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* @typedef {import('@applitools/types').Core} Core
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const _ = require('lodash');
|
|
8
8
|
const { makeSDK } = require('@applitools/eyes-sdk-core');
|
|
9
9
|
const { W3C_ELEMENT_ID } = require('../constants');
|
|
10
|
-
const
|
|
10
|
+
const { EyeSdkBuilder } = require('../../commons/getSessionPlayerRequire');
|
|
11
11
|
|
|
12
12
|
let packageJson;
|
|
13
13
|
// There is a difference in the folder structure in prod vs. dev
|
|
@@ -41,13 +41,6 @@ function extractElementId(element) {
|
|
|
41
41
|
}
|
|
42
42
|
return undefined;
|
|
43
43
|
}
|
|
44
|
-
/** implements the ?? capability for backward compatibility */
|
|
45
|
-
function getValueOrFallbackIfNullOrUndefined(value, fallback) {
|
|
46
|
-
if (value === null || value === undefined) {
|
|
47
|
-
return fallback;
|
|
48
|
-
}
|
|
49
|
-
return value;
|
|
50
|
-
}
|
|
51
44
|
|
|
52
45
|
/**
|
|
53
46
|
* Applitools Spec Driver for webdriverIO 4.
|
|
@@ -57,7 +50,7 @@ function getValueOrFallbackIfNullOrUndefined(value, fallback) {
|
|
|
57
50
|
class EyesSpec {
|
|
58
51
|
// #region UTILITY
|
|
59
52
|
isDriver(driver) {
|
|
60
|
-
return Boolean(driver
|
|
53
|
+
return Boolean(driver?.getPrototype && driver.desiredCapabilities && driver.requestHandler);
|
|
61
54
|
}
|
|
62
55
|
|
|
63
56
|
isElement(element) {
|
|
@@ -69,7 +62,7 @@ class EyesSpec {
|
|
|
69
62
|
}
|
|
70
63
|
|
|
71
64
|
isSelector(selector) {
|
|
72
|
-
return
|
|
65
|
+
return typeof selector === 'string';
|
|
73
66
|
}
|
|
74
67
|
|
|
75
68
|
transformDriver(driver) {
|
|
@@ -176,8 +169,8 @@ class EyesSpec {
|
|
|
176
169
|
deviceName: desiredCapabilities.deviceName,
|
|
177
170
|
platformName: desiredCapabilities.platformName || desiredCapabilities.platform,
|
|
178
171
|
platformVersion: desiredCapabilities.platformVersion,
|
|
179
|
-
browserName:
|
|
180
|
-
browserVersion:
|
|
172
|
+
browserName: desiredCapabilities.browserName ?? desiredCapabilities.name,
|
|
173
|
+
browserVersion: desiredCapabilities.browserVersion ?? desiredCapabilities.version,
|
|
181
174
|
pixelRatio: desiredCapabilities.pixelRatio,
|
|
182
175
|
};
|
|
183
176
|
}
|
|
@@ -209,7 +202,7 @@ class EyesSpec {
|
|
|
209
202
|
if (this.isSelector(element)) {
|
|
210
203
|
element = await this.findElement(driver, element);
|
|
211
204
|
}
|
|
212
|
-
await driver.moveTo(extractElementId(element), offset
|
|
205
|
+
await driver.moveTo(extractElementId(element), offset?.x, offset?.y);
|
|
213
206
|
}
|
|
214
207
|
|
|
215
208
|
async type(driver, element, keys) {
|
|
@@ -242,7 +235,6 @@ class EyeSdkService {
|
|
|
242
235
|
name: 'Testim.io',
|
|
243
236
|
version: `4.0.0/eyes-sdk-core/${sdkVersion}`,
|
|
244
237
|
spec: new EyesSpec(),
|
|
245
|
-
VisualGridClient: require('@applitools/visual-grid-client'),
|
|
246
238
|
});
|
|
247
239
|
/** @type {EyeSdkBuilder['handleApplitoolsSdkResult']} */
|
|
248
240
|
this.handleApplitoolsSdkResult = EyeSdkBuilder.handleApplitoolsSdkResult;
|