@testim/testim-cli 3.262.0 → 3.264.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/cli.js +11 -5
- package/commons/featureFlags.js +2 -3
- package/commons/testimDesiredCapabilitiesBuilder.js +24 -67
- package/npm-shrinkwrap.json +82 -82
- package/package.json +1 -1
- 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/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/webdriver.js +13 -35
- package/polyfills/Array.prototype.at.js +13 -0
- package/polyfills/index.js +1 -0
- package/runOptions.d.ts +1 -1
- package/runOptions.js +1 -9
- package/runner.js +7 -0
- package/runners/runnerUtils.js +1 -1
- package/testRunStatus.js +4 -0
- package/utils/index.js +9 -2
- package/player/stepActions/scripts/polyfills.js +0 -393
|
@@ -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) {
|
|
@@ -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
|
}
|
package/player/webdriver.js
CHANGED
|
@@ -80,8 +80,7 @@ class WebDriver extends WebDriverApi {
|
|
|
80
80
|
if (capabilities.capabilities) {
|
|
81
81
|
delete capabilities.capabilities.alwaysMatch.marionette;
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
this.initUnsupportedActions(browser, lambdatestService?.isLambdatestRun());
|
|
83
|
+
this.initUnsupportedActions(lambdatestService?.isLambdatestRun());
|
|
85
84
|
this.browserAndOS = null;
|
|
86
85
|
this.seleniumPerfStats = seleniumPerfStats;
|
|
87
86
|
const driverDelay = fastInit ? 0 : 1500;
|
|
@@ -110,8 +109,8 @@ class WebDriver extends WebDriverApi {
|
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
initUnsupportedActions(
|
|
114
|
-
if (isLambdatestRun
|
|
112
|
+
initUnsupportedActions(isLambdatestRun) {
|
|
113
|
+
if (isLambdatestRun) {
|
|
115
114
|
this.unsupportedActions = {
|
|
116
115
|
...this.unsupportedActions,
|
|
117
116
|
move: true,
|
|
@@ -391,15 +390,7 @@ class WebDriver extends WebDriverApi {
|
|
|
391
390
|
if (isTextElement(element)) {
|
|
392
391
|
return element.value;
|
|
393
392
|
} else if (element instanceof SVGElement) {
|
|
394
|
-
var isIE = navigator.userAgent.indexOf('MSIE') !== -1
|
|
395
|
-
|| navigator.userAgent.indexOf('Trident/') !== -1;
|
|
396
|
-
|
|
397
393
|
var copyElement = element.cloneNode(true);
|
|
398
|
-
// clone doesn't work for SVG elements in IE11
|
|
399
|
-
if (isIE) {
|
|
400
|
-
var svgContent = new XMLSerializer().serializeToString(element);
|
|
401
|
-
copyElement = new DOMParser().parseFromString(svgContent, 'text/html').body.firstChild;
|
|
402
|
-
}
|
|
403
394
|
return clearTitleTags(copyElement).textContent.replace(/(\r\n|\n|\r)/gm, '');
|
|
404
395
|
} else {
|
|
405
396
|
return getFixedTextContent(element);
|
|
@@ -436,9 +427,6 @@ class WebDriver extends WebDriverApi {
|
|
|
436
427
|
return this.executeJS(getHTMLCode)
|
|
437
428
|
.then(result => {
|
|
438
429
|
this.seleniumPerfStats.markEnd(perfId, SELENIUM_PERF_MARKS.GET_HTML);
|
|
439
|
-
if (this.isIE() && result.value.runLocation && this.isIePageNotAvailableUrl(result.value.runLocation.href)) {
|
|
440
|
-
throw this.getIeError('Page is not loaded');
|
|
441
|
-
}
|
|
442
430
|
return result.value;
|
|
443
431
|
})
|
|
444
432
|
.catch(err => !(err instanceof IeError), err => {
|
|
@@ -449,15 +437,7 @@ class WebDriver extends WebDriverApi {
|
|
|
449
437
|
testimInternalError.extraInfo = 'Inside getHtml catch and trying to check if in quirks mode - but the session has already terminated';
|
|
450
438
|
throw testimInternalError;
|
|
451
439
|
}
|
|
452
|
-
|
|
453
|
-
throw testimInternalError;
|
|
454
|
-
}
|
|
455
|
-
return this.executeJS('return navigator.userAgent;')
|
|
456
|
-
.catch(() => { throw testimInternalError; })
|
|
457
|
-
.then(ua => {
|
|
458
|
-
const error = this.isUsingUnsupportedCompabilityMode(ua.value) ? this.getIeError('Can’t run test in IE compatibility mode') : testimInternalError;
|
|
459
|
-
throw error;
|
|
460
|
-
});
|
|
440
|
+
throw testimInternalError;
|
|
461
441
|
});
|
|
462
442
|
}
|
|
463
443
|
|
|
@@ -469,10 +449,9 @@ class WebDriver extends WebDriverApi {
|
|
|
469
449
|
const MAX_TRIES = 5;
|
|
470
450
|
|
|
471
451
|
const getViewportSizeScript = function () {
|
|
472
|
-
var pixelRatio = (/(MSIE)|(Trident)/.test(navigator.userAgent)) ? (window.screen.systemXDPI / window.screen.deviceXDPI) : 1;
|
|
473
452
|
return {
|
|
474
|
-
screenWidth: Math.floor(window.innerWidth || 0)
|
|
475
|
-
screenHeight: Math.floor(window.innerHeight || 0)
|
|
453
|
+
screenWidth: Math.floor(window.innerWidth || 0),
|
|
454
|
+
screenHeight: Math.floor(window.innerHeight || 0)
|
|
476
455
|
};
|
|
477
456
|
};
|
|
478
457
|
|
|
@@ -649,15 +628,14 @@ class WebDriver extends WebDriverApi {
|
|
|
649
628
|
}
|
|
650
629
|
|
|
651
630
|
doubleClickWithJS(eventData) {
|
|
652
|
-
const eventParam = this.isEdge() ? JSON.stringify(eventData) : eventData;
|
|
653
631
|
return this.executeCodeAsync(`
|
|
654
632
|
var getLocatedElement = ${codeSnippets().getLocatedElementCode};
|
|
655
633
|
var dispatchFocus = ${dispatchFocus.toString()};
|
|
656
634
|
var doubleClick = ${doubleClick.toString()};
|
|
657
|
-
var eventData =
|
|
635
|
+
var eventData = arguments[0];
|
|
658
636
|
var done = arguments[1];
|
|
659
637
|
return doubleClick.call(null, eventData, done);
|
|
660
|
-
`, eventData.timeout,
|
|
638
|
+
`, eventData.timeout, eventData);
|
|
661
639
|
}
|
|
662
640
|
|
|
663
641
|
// eslint-disable-next-line default-param-last
|
|
@@ -740,8 +718,8 @@ class WebDriver extends WebDriverApi {
|
|
|
740
718
|
const { rect, clickOffset } = offsets;
|
|
741
719
|
const center = this.inViewCenter(rect);
|
|
742
720
|
// moveto element (actions and legacy) is always vs. the center of an element, so the offset needs to get fixed.
|
|
743
|
-
const xOffset =
|
|
744
|
-
const yOffset =
|
|
721
|
+
const xOffset = Math.floor(clickOffset.x - center.x);
|
|
722
|
+
const yOffset = Math.floor(clickOffset.y - center.y);
|
|
745
723
|
|
|
746
724
|
return this.moveTo(extractElementId(seleniumElement), xOffset, yOffset)
|
|
747
725
|
.catch(err => {
|
|
@@ -813,8 +791,8 @@ class WebDriver extends WebDriverApi {
|
|
|
813
791
|
|
|
814
792
|
drag(seleniumElement, targetRect, xElementOffset, yElementOffset, events) {
|
|
815
793
|
const { width, height } = targetRect;
|
|
816
|
-
const midXRelative =
|
|
817
|
-
const midYRelative =
|
|
794
|
+
const midXRelative = (xElementOffset - width / 2 + 1);
|
|
795
|
+
const midYRelative = (yElementOffset - height / 2);
|
|
818
796
|
return this.getDragCoordinates(events)
|
|
819
797
|
.then(coordinates => {
|
|
820
798
|
const { xDiff, yDiff } = coordinates;
|
|
@@ -893,7 +871,7 @@ class WebDriver extends WebDriverApi {
|
|
|
893
871
|
}
|
|
894
872
|
|
|
895
873
|
dragAndDrop(sourceSeleniumElement, destinationSeleniumElement, rectsAndOffsets) {
|
|
896
|
-
if (this.
|
|
874
|
+
if (this.isSafari()) {
|
|
897
875
|
if (this.unsupportedActions.move) {
|
|
898
876
|
return this.dragAndDropWithActionsAPIWithGeneratedMoves(rectsAndOffsets);
|
|
899
877
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* eslint-disable no-extend-native */
|
|
2
|
+
|
|
3
|
+
Array.prototype.at = Array.prototype.at || function (index) {
|
|
4
|
+
const relativeIndex = Number.isInteger(index) ? index : 0;
|
|
5
|
+
|
|
6
|
+
const indexToRead = relativeIndex >= 0 ? relativeIndex : this.length + relativeIndex;
|
|
7
|
+
|
|
8
|
+
if (indexToRead < 0 || indexToRead >= this.length) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return this[indexToRead];
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('./Array.prototype.at');
|
package/runOptions.d.ts
CHANGED
|
@@ -163,7 +163,7 @@ interface RunnerOptions extends Partial<Omit<TunnelOptions, 'tunnelOnlyMode' | '
|
|
|
163
163
|
useChromeLauncher?: boolean;
|
|
164
164
|
|
|
165
165
|
disableGridCheck: boolean;
|
|
166
|
-
browser?: '
|
|
166
|
+
browser?: 'edge-chromium' | 'firefox' | 'safari' | 'chrome';
|
|
167
167
|
|
|
168
168
|
proxyForGrid: string;
|
|
169
169
|
|
package/runOptions.js
CHANGED
|
@@ -452,13 +452,8 @@ module.exports = {
|
|
|
452
452
|
|
|
453
453
|
if (program.playerRequirePath) {
|
|
454
454
|
const fullPlayerPath = path.resolve(program.playerRequirePath);
|
|
455
|
-
let projectFile;
|
|
456
455
|
console.log('Using Local Clickim for Player Require Path =', fullPlayerPath);
|
|
457
|
-
|
|
458
|
-
projectFile = path.join(fullPlayerPath, 'tsconfig.ie11.json');
|
|
459
|
-
} else {
|
|
460
|
-
projectFile = path.join(fullPlayerPath, 'tsconfig.node.json');
|
|
461
|
-
}
|
|
456
|
+
const projectFile = path.join(fullPlayerPath, 'tsconfig.node.json');
|
|
462
457
|
|
|
463
458
|
// [NOTE] playerRequirePath is a dev flag
|
|
464
459
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
@@ -655,9 +650,6 @@ module.exports = {
|
|
|
655
650
|
case 'microsoftedge':
|
|
656
651
|
program.browser = 'edge';
|
|
657
652
|
break;
|
|
658
|
-
case 'internet explorer':
|
|
659
|
-
program.browser = 'ie';
|
|
660
|
-
break;
|
|
661
653
|
default:
|
|
662
654
|
program.browser = browserName;
|
|
663
655
|
}
|