@testim/testim-cli 3.289.0 → 3.290.1-beta
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 +22390 -122
- package/cli.js.map +1 -0
- package/npm-shrinkwrap.json +1169 -12846
- package/package.json +16 -10
- package/OverrideTestDataBuilder.js +0 -117
- package/agent/routers/cliJsCode/index.js +0 -13
- package/agent/routers/cliJsCode/router.js +0 -63
- package/agent/routers/cliJsCode/service.js +0 -705
- package/agent/routers/codim/router.js +0 -69
- package/agent/routers/codim/router.test.js +0 -60
- package/agent/routers/codim/service.js +0 -193
- package/agent/routers/general/index.js +0 -36
- package/agent/routers/hybrid/registerRoutes.js +0 -81
- package/agent/routers/index.js +0 -56
- package/agent/routers/playground/router.js +0 -77
- package/agent/routers/playground/service.js +0 -96
- package/agent/routers/standalone-browser/registerRoutes.js +0 -47
- package/agent/server.js +0 -150
- package/cdpTestRunner.js +0 -86
- package/chromiumInstaller.js +0 -91
- package/cli/isCiRun.js +0 -10
- package/cli/onExit.js +0 -65
- package/cli/writeStackTrace.js +0 -27
- package/cliAgentMode.js +0 -384
- package/codim/codim-cli.js +0 -91
- package/codim/codim-npm-package/index.ts +0 -427
- package/codim/codim-npm-package/package-lock.json +0 -14
- package/codim/codim-npm-package/package.json +0 -14
- package/codim/hybrid-utils.js +0 -28
- package/codim/measure-perf.js +0 -41
- package/codim/template.js/.idea/workspace.xml +0 -57
- package/codim/template.js/.vscode/launch.json +0 -53
- package/codim/template.ts/.idea/workspace.xml +0 -57
- package/codim/template.ts/.vscode/launch.json +0 -55
- package/commons/AbortError.js +0 -12
- package/commons/SeleniumPerfStats.js +0 -58
- package/commons/chrome-launcher.js +0 -15
- package/commons/chromedriverWrapper.js +0 -70
- package/commons/config.js +0 -39
- package/commons/constants.js +0 -67
- package/commons/detectDebugger.js +0 -19
- package/commons/featureAvailabilityService.js +0 -26
- package/commons/featureFlags.js +0 -132
- package/commons/getSessionPlayerRequire.js +0 -28
- package/commons/httpRequest.js +0 -261
- package/commons/httpRequestCounters.js +0 -98
- package/commons/httpRequestCounters.test.js +0 -38
- package/commons/initializeUserWithAuth.js +0 -55
- package/commons/lazyRequire.js +0 -105
- package/commons/logUtils.js +0 -15
- package/commons/logUtils.test.js +0 -21
- package/commons/logger.js +0 -178
- package/commons/mockNetworkRuleFileSchema.json +0 -140
- package/commons/npmWrapper.js +0 -174
- package/commons/npmWrapper.test.js +0 -374
- package/commons/performance-logger.js +0 -71
- package/commons/preloadTests.js +0 -29
- package/commons/prepareRunner.js +0 -85
- package/commons/prepareRunner.test.js +0 -144
- package/commons/prepareRunnerAndTestimStartUtils.js +0 -198
- package/commons/prepareRunnerAndTestimStartUtils.test.js +0 -73
- package/commons/requireWithFallback.js +0 -25
- package/commons/runnerFileCache.js +0 -204
- package/commons/socket/baseSocketServiceSocketIO.js +0 -197
- package/commons/socket/realDataService.js +0 -59
- package/commons/socket/realDataServiceSocketIO.js +0 -33
- package/commons/socket/remoteStepService.js +0 -55
- package/commons/socket/remoteStepServiceSocketIO.js +0 -61
- package/commons/socket/socketService.js +0 -175
- package/commons/socket/testResultService.js +0 -62
- package/commons/socket/testResultServiceSocketIO.js +0 -64
- package/commons/testimAnalytics.js +0 -40
- package/commons/testimCloudflare.js +0 -83
- package/commons/testimCloudflare.test.js +0 -185
- package/commons/testimCustomToken.js +0 -124
- package/commons/testimDesiredCapabilitiesBuilder.js +0 -647
- package/commons/testimNgrok.js +0 -90
- package/commons/testimNgrok.test.js +0 -140
- package/commons/testimServicesApi.js +0 -631
- package/commons/testimTunnel.js +0 -73
- package/commons/testimTunnel.test.js +0 -172
- package/commons/xhr2.js +0 -897
- package/coverage/SummaryToObjectReport.js +0 -19
- package/coverage/jsCoverage.js +0 -252
- package/credentialsManager.js +0 -142
- package/errors.js +0 -161
- package/executionQueue.js +0 -37
- package/fixLocalBuild.js +0 -24
- package/inputFileUtils.js +0 -103
- package/lib/coralogix-winston.transport.js +0 -99
- package/player/SeleniumProtocolError.js +0 -100
- package/player/WebDriverHttpRequest.js +0 -177
- package/player/WebdriverioWebDriverApi.js +0 -671
- package/player/appiumTestPlayer.js +0 -90
- package/player/chromeLauncherTestPlayer.js +0 -67
- package/player/constants.js +0 -332
- package/player/extensionTestPlayer.js +0 -32
- package/player/findElementStrategy.js +0 -154
- package/player/scripts/isElementDisplayed.js +0 -252
- package/player/seleniumTestPlayer.js +0 -140
- package/player/services/frameLocator.js +0 -170
- package/player/services/mobileFrameLocatorMock.js +0 -32
- package/player/services/playbackTimeoutCalculator.js +0 -175
- package/player/services/portSelector.js +0 -19
- package/player/services/tabService.js +0 -551
- package/player/services/tabServiceMock.js +0 -167
- package/player/services/windowCreationListener.js +0 -8
- package/player/stepActions/RefreshStepAction.js +0 -16
- package/player/stepActions/apiStepAction.js +0 -89
- package/player/stepActions/baseCliJsStepAction.js +0 -51
- package/player/stepActions/baseJsStepAction.js +0 -277
- package/player/stepActions/cliConditionStepAction.js +0 -11
- package/player/stepActions/cliJsStepAction.js +0 -11
- package/player/stepActions/dropFileStepAction.js +0 -34
- package/player/stepActions/evaluateExpressionStepAction.js +0 -52
- package/player/stepActions/extensionOnlyStepAction.js +0 -12
- package/player/stepActions/extractTextStepAction.js +0 -19
- package/player/stepActions/hoverStepAction.js +0 -55
- package/player/stepActions/inputFileStepAction.js +0 -199
- package/player/stepActions/jsCodeStepAction.js +0 -11
- package/player/stepActions/jsConditionStepAction.js +0 -11
- package/player/stepActions/locateStepAction.js +0 -159
- package/player/stepActions/mouseStepAction.js +0 -370
- package/player/stepActions/navigationStepAction.js +0 -29
- package/player/stepActions/nodePackageStepAction.js +0 -47
- package/player/stepActions/pixelValidationStepAction.js +0 -39
- package/player/stepActions/scripts/dispatchEvents.js +0 -282
- package/player/stepActions/scripts/doClick.js +0 -221
- package/player/stepActions/scripts/doDragPath.js +0 -225
- package/player/stepActions/scripts/doubleClick.js +0 -119
- package/player/stepActions/scripts/dropEvent.js +0 -63
- package/player/stepActions/scripts/focusElement.js +0 -46
- package/player/stepActions/scripts/html5dragAction.js +0 -56
- package/player/stepActions/scripts/html5dragActionV2.js +0 -312
- package/player/stepActions/scripts/runCode.js +0 -147
- package/player/stepActions/scripts/scroll.js +0 -90
- package/player/stepActions/scripts/selectOption.js +0 -51
- package/player/stepActions/scripts/setText.js +0 -415
- package/player/stepActions/scripts/wheel.js +0 -61
- package/player/stepActions/scrollStepAction.js +0 -96
- package/player/stepActions/selectOptionStepAction.js +0 -49
- package/player/stepActions/sfdcRecordedStepAction.js +0 -24
- package/player/stepActions/sfdcStepAction.js +0 -28
- package/player/stepActions/sleepStepAction.js +0 -12
- package/player/stepActions/specialKeyStepAction.js +0 -52
- package/player/stepActions/stepAction.js +0 -73
- package/player/stepActions/stepActionRegistrar.js +0 -111
- package/player/stepActions/submitStepAction.js +0 -12
- package/player/stepActions/tdkHybridStepAction.js +0 -18
- package/player/stepActions/textStepAction.js +0 -110
- package/player/stepActions/textValidationStepAction.js +0 -64
- package/player/stepActions/wheelStepAction.js +0 -41
- package/player/utils/cookieUtils.js +0 -39
- package/player/utils/eyeSdkService.js +0 -250
- package/player/utils/imageCaptureUtils.js +0 -267
- package/player/utils/screenshotUtils.js +0 -68
- package/player/utils/stepActionUtils.js +0 -90
- package/player/utils/windowUtils.js +0 -195
- package/player/webDriverUtils.js +0 -40
- package/player/webDriverUtils.test.js +0 -116
- package/player/webdriver.js +0 -976
- package/polyfills/Array.prototype.at.js +0 -13
- package/polyfills/index.js +0 -13
- package/processHandler.js +0 -79
- package/processHandler.test.js +0 -55
- package/reports/chromeReporter.js +0 -17
- package/reports/consoleReporter.js +0 -190
- package/reports/debugReporter.js +0 -82
- package/reports/jsonReporter.js +0 -55
- package/reports/junitReporter.js +0 -183
- package/reports/reporter.js +0 -166
- package/reports/reporterUtils.js +0 -54
- package/reports/teamCityReporter.js +0 -73
- package/runOptions.d.ts +0 -305
- package/runOptions.js +0 -1288
- package/runOptionsAgentFlow.js +0 -87
- package/runOptionsUtils.js +0 -60
- package/runner.js +0 -355
- package/runners/ParallelWorkerManager.js +0 -284
- package/runners/TestPlanRunner.js +0 -419
- package/runners/buildCodeTests.js +0 -159
- package/runners/runnerUtils.js +0 -81
- package/services/analyticsService.js +0 -96
- package/services/branchService.js +0 -29
- package/services/gridService.js +0 -357
- package/services/gridService.test.js +0 -357
- package/services/labFeaturesService.js +0 -64
- package/services/lambdatestService.js +0 -227
- package/services/lambdatestService.test.js +0 -353
- package/services/localRCASaver.js +0 -124
- package/stepPlayers/cliJsStepPlayback.js +0 -40
- package/stepPlayers/hybridStepPlayback.js +0 -140
- package/stepPlayers/nodePackageStepPlayback.js +0 -28
- package/stepPlayers/playwrightHybridStepPlayback.js +0 -61
- package/stepPlayers/puppeteerHybridStepPlayback.js +0 -76
- package/stepPlayers/remoteStepPlayback.js +0 -80
- package/stepPlayers/seleniumHybridStepPlayback.js +0 -84
- package/stepPlayers/tdkHybridStepPlayback.js +0 -112
- package/testRunHandler.js +0 -603
- package/testRunStatus.js +0 -567
- package/testimNpmDriver.js +0 -52
- package/utils/argsUtils.js +0 -91
- package/utils/argsUtils.test.js +0 -32
- package/utils/fsUtils.js +0 -174
- package/utils/index.js +0 -197
- package/utils/promiseUtils.js +0 -85
- package/utils/stringUtils.js +0 -98
- package/utils/stringUtils.test.js +0 -22
- package/utils/timeUtils.js +0 -25
- package/utils/utils.test.js +0 -27
- package/workers/BaseWorker.js +0 -498
- package/workers/BaseWorker.test.js +0 -186
- package/workers/WorkerAppium.js +0 -180
- package/workers/WorkerExtension.js +0 -192
- package/workers/WorkerExtensionSingleBrowser.js +0 -77
- package/workers/WorkerSelenium.js +0 -253
- package/workers/workerUtils.js +0 -20
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
/* global getLocatedElement */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const html5dndAction = function (eventData, done) {
|
|
6
|
-
const mouseEventConstructorSupported = typeof MouseEvent === 'function';
|
|
7
|
-
const dragEventConstructorSupported = typeof DragEvent === 'function';
|
|
8
|
-
const pointerEventConstructorSupported = typeof PointerEvent === 'function';
|
|
9
|
-
const data = {};
|
|
10
|
-
|
|
11
|
-
window.__unloadNavigator = resolve;
|
|
12
|
-
|
|
13
|
-
window.addEventListener('unload', window.__unloadNavigator);
|
|
14
|
-
|
|
15
|
-
function resolve(result) {
|
|
16
|
-
const status = {
|
|
17
|
-
status: 'done',
|
|
18
|
-
result,
|
|
19
|
-
success: true,
|
|
20
|
-
};
|
|
21
|
-
done(status);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function reject(result) {
|
|
25
|
-
result = result || {};
|
|
26
|
-
const status = {
|
|
27
|
-
status: 'failed',
|
|
28
|
-
result,
|
|
29
|
-
success: false,
|
|
30
|
-
keep: true,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
done(status);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function convertType(type) {
|
|
37
|
-
if (!type?.toLowerCase) {
|
|
38
|
-
return type;
|
|
39
|
-
}
|
|
40
|
-
type = type.toLowerCase();
|
|
41
|
-
if (type === 'text') {
|
|
42
|
-
return 'text/plain';
|
|
43
|
-
}
|
|
44
|
-
if (type === 'url') {
|
|
45
|
-
return 'text/uri-list';
|
|
46
|
-
}
|
|
47
|
-
return type;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function createDataTransfer() {
|
|
51
|
-
try {
|
|
52
|
-
return new DataTransfer();
|
|
53
|
-
} catch (err) {
|
|
54
|
-
return {
|
|
55
|
-
data: {},
|
|
56
|
-
setData(type, val) {
|
|
57
|
-
data[convertType(type)] = val;
|
|
58
|
-
},
|
|
59
|
-
getData(type) {
|
|
60
|
-
return data[convertType(type)];
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const dragFromElementEvents = ['drag', 'dragstart', 'dragend'];
|
|
67
|
-
const pointerEvents = ['pointerup', 'pointerdown', 'pointermove'];
|
|
68
|
-
const dragEvents = dragFromElementEvents.concat(['drop', 'dragenter', 'dragover']);
|
|
69
|
-
|
|
70
|
-
function findClosestDraggable(element) {
|
|
71
|
-
// drag events are always fired on the closest element with draggable=true
|
|
72
|
-
// rather than on the target mouse element - so when dispatching a drag
|
|
73
|
-
// event we need to fire the correct target
|
|
74
|
-
let current = element;
|
|
75
|
-
while (current && current !== document.documentElement) {
|
|
76
|
-
if (current.draggable) {
|
|
77
|
-
return current;
|
|
78
|
-
}
|
|
79
|
-
current = current.parentElement;
|
|
80
|
-
}
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function getElement(event, context, currentEvent) {
|
|
85
|
-
const element = context.element;
|
|
86
|
-
const dispatchDragEventsOnClosestDraggable = currentEvent.dispatchDragEventsOnClosestDraggable;
|
|
87
|
-
if (dragFromElementEvents.includes(event.type) && dispatchDragEventsOnClosestDraggable) {
|
|
88
|
-
if (!element && context.lastDraggedElement) {
|
|
89
|
-
// fallback for elements being removed from DOM, but parent draggable still being there
|
|
90
|
-
return context.lastDraggedElement;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const draggable = findClosestDraggable(element);
|
|
94
|
-
if (draggable) {
|
|
95
|
-
context.lastDraggedElement = draggable;
|
|
96
|
-
return draggable;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return element;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function getEventPosition(userEvent, isDrag, element) {
|
|
103
|
-
function isWithinBounds(start, end, point) {
|
|
104
|
-
return (point > start) && (point < end);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const pointerPosition = userEvent.pointerPosition || {};
|
|
108
|
-
// Technically should always be true here.
|
|
109
|
-
if (isDrag) {
|
|
110
|
-
return { x: pointerPosition.originX || 0, y: pointerPosition.originY || 0 };
|
|
111
|
-
}
|
|
112
|
-
const rect = element.getBoundingClientRect();
|
|
113
|
-
const clientX = pointerPosition.originX && isWithinBounds(rect.left, rect.left + rect.width, pointerPosition.originX) ? pointerPosition.originX : rect.left + (rect.width / 2);
|
|
114
|
-
const clientY = pointerPosition.originY && isWithinBounds(rect.top, rect.top + rect.height, pointerPosition.originY) ? pointerPosition.originY : rect.top + (rect.height / 2);
|
|
115
|
-
return { x: clientX, y: clientY };
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function getMouseEvent(userEvent, eventData, context) {
|
|
119
|
-
const modifiers = eventData?.modifiers || {};
|
|
120
|
-
const pos = getEventPosition(userEvent, context.isDrag, context.element);
|
|
121
|
-
const button = eventData?.button || 0;
|
|
122
|
-
const eventType = userEvent.event;
|
|
123
|
-
if (pointerEvents.includes(eventType)) {
|
|
124
|
-
return createPointerEvent(eventType, modifiers, pos.x, pos.y, button);
|
|
125
|
-
}
|
|
126
|
-
if (dragEvents.includes(eventType)) {
|
|
127
|
-
return createDragEvent(eventType, modifiers, pos.x, pos.y, button);
|
|
128
|
-
}
|
|
129
|
-
return createMouseEvent(eventType, modifiers, pos.x, pos.y, button);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function getEventDictionary(modifiers, clientX, clientY) {
|
|
133
|
-
return {
|
|
134
|
-
screenX: 0,
|
|
135
|
-
screenY: 0,
|
|
136
|
-
clientX,
|
|
137
|
-
clientY,
|
|
138
|
-
ctrlKey: Boolean(modifiers.ctrl),
|
|
139
|
-
altKey: Boolean(modifiers.alt),
|
|
140
|
-
shiftKey: Boolean(modifiers.shift),
|
|
141
|
-
metaKey: Boolean(modifiers.meta),
|
|
142
|
-
bubbles: true,
|
|
143
|
-
cancelable: true,
|
|
144
|
-
composed: true,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function createPointerEvent(eventType, modifiers, clientX, clientY, button) {
|
|
149
|
-
if (pointerEventConstructorSupported) {
|
|
150
|
-
const eventProperties = getEventDictionary(modifiers, clientX, clientY);
|
|
151
|
-
eventProperties.pointerType = 'mouse';
|
|
152
|
-
eventProperties.isPrimary = true;
|
|
153
|
-
return new window.PointerEvent(eventType, eventProperties);
|
|
154
|
-
}
|
|
155
|
-
const event = document.createEvent('PointerEvent');
|
|
156
|
-
event.initPointerEvent(
|
|
157
|
-
eventType,
|
|
158
|
-
true, /* bubbles */
|
|
159
|
-
true, /* cancelable */
|
|
160
|
-
document.defaultView, /* view */
|
|
161
|
-
1, /* detail */
|
|
162
|
-
0, /* screenX */
|
|
163
|
-
0, /* screenY */
|
|
164
|
-
clientX, /* clientX */
|
|
165
|
-
clientY, /* clientY */
|
|
166
|
-
Boolean(modifiers.ctrl), /* ctrl */
|
|
167
|
-
Boolean(modifiers.alt), /* alt */
|
|
168
|
-
Boolean(modifiers.shift), /* shift */
|
|
169
|
-
Boolean(modifiers.meta), /* meta */
|
|
170
|
-
button, /* button */
|
|
171
|
-
document.body ? document.body.parentNode : document.documentElement,
|
|
172
|
-
0, /* offsetYArg */
|
|
173
|
-
0, /* offsetXArg */
|
|
174
|
-
0, /* widthArg */
|
|
175
|
-
0, /* heightArg */
|
|
176
|
-
0, /* pressure */
|
|
177
|
-
0, /* rotation */
|
|
178
|
-
0, /* tiltX */
|
|
179
|
-
0, /* tiltY */
|
|
180
|
-
0, /* pointerIdArg */
|
|
181
|
-
'mouse', /* pointerType */
|
|
182
|
-
0, /* hwTimestampArg */
|
|
183
|
-
true, /* isPrimary */
|
|
184
|
-
);
|
|
185
|
-
return event;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function createMouseEvent(eventType, modifiers, clientX, clientY, button) {
|
|
189
|
-
const event = mouseEventConstructorSupported ? new MouseEvent('click', { composed: true }) : document.createEvent('MouseEvents');
|
|
190
|
-
event.initMouseEvent(
|
|
191
|
-
eventType,
|
|
192
|
-
true, /* bubbles */
|
|
193
|
-
true, /* cancelable */
|
|
194
|
-
document.defaultView, /* view */
|
|
195
|
-
1, /* detail */
|
|
196
|
-
0, /* screenX */
|
|
197
|
-
0, /* screenY */
|
|
198
|
-
clientX, /* clientX */
|
|
199
|
-
clientY, /* clientY */
|
|
200
|
-
Boolean(modifiers.ctrl), /* ctrl */
|
|
201
|
-
Boolean(modifiers.alt), /* alt */
|
|
202
|
-
Boolean(modifiers.shift), /* shift */
|
|
203
|
-
Boolean(modifiers.meta), /* meta */
|
|
204
|
-
button, /* button */
|
|
205
|
-
document.body ? document.body.parentNode : document.documentElement);
|
|
206
|
-
return event;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function createDragEvent(eventType, modifiers, clientX, clientY) {
|
|
210
|
-
if (eventType === 'dragstart') {
|
|
211
|
-
if (!window.TSTA) {
|
|
212
|
-
window.TSTA = {};
|
|
213
|
-
}
|
|
214
|
-
window.TSTA.dataTransfer = createDataTransfer();
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (!dragEventConstructorSupported) {
|
|
218
|
-
const event = document.createEvent('CustomEvent');
|
|
219
|
-
event.initCustomEvent(eventType, true, true, null);
|
|
220
|
-
event.dataTransfer = window.TSTA.dataTransfer;
|
|
221
|
-
return event;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const eventProperties = getEventDictionary(modifiers, clientX, clientY);
|
|
225
|
-
const event = new window.DragEvent(eventType, eventProperties);
|
|
226
|
-
Object.defineProperties(event, {
|
|
227
|
-
dataTransfer: { get() { return window.TSTA.dataTransfer; } },
|
|
228
|
-
});
|
|
229
|
-
return event;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function executeAsyncEvent(event, context, currentEvent) {
|
|
233
|
-
const element = getElement(event, context, currentEvent);
|
|
234
|
-
if (element) {
|
|
235
|
-
element.dispatchEvent(event);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function shouldSkipEvent(currentEvent, context) {
|
|
240
|
-
function isClickInDragAndDrop() {
|
|
241
|
-
return currentEvent.event === 'click' &&
|
|
242
|
-
context.isDrag &&
|
|
243
|
-
!context.allEventsOnSameElement;
|
|
244
|
-
}
|
|
245
|
-
return isClickInDragAndDrop();
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function nextAsyncEvent(context, currentEvent, nextEvent) {
|
|
249
|
-
if (nextEvent) {
|
|
250
|
-
const delay = Math.min(nextEvent.timeStamp - currentEvent.timeStamp, 40);
|
|
251
|
-
setTimeout(() => {
|
|
252
|
-
executeAsyncNext(context);
|
|
253
|
-
}, delay);
|
|
254
|
-
} else {
|
|
255
|
-
if (window.__unloadNavigator) {
|
|
256
|
-
window.removeEventListener('unload', window.__unloadNavigator);
|
|
257
|
-
}
|
|
258
|
-
resolve();
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function executeAsyncNext(context) {
|
|
263
|
-
let event;
|
|
264
|
-
const currentEvent = context.events[context.eventIndex];
|
|
265
|
-
// eslint-disable-next-line no-param-reassign
|
|
266
|
-
const nextEvent = context.events[++context.eventIndex];
|
|
267
|
-
try {
|
|
268
|
-
context.element = getLocatedElement(currentEvent.locatedElement);
|
|
269
|
-
event = getMouseEvent(currentEvent, eventData, context);
|
|
270
|
-
} catch (err) {
|
|
271
|
-
return reject(`exception in get event in drag step:${err.message}`);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (shouldSkipEvent(currentEvent, context)) {
|
|
275
|
-
return nextAsyncEvent(context, currentEvent, nextEvent);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
if (event) {
|
|
279
|
-
try {
|
|
280
|
-
executeAsyncEvent(event, context, currentEvent);
|
|
281
|
-
} catch (err) {
|
|
282
|
-
return reject(`exception in executeEvent in drag step:${err.message}`);
|
|
283
|
-
}
|
|
284
|
-
} else {
|
|
285
|
-
return reject(`cannot execute event ${currentEvent.event}`);
|
|
286
|
-
}
|
|
287
|
-
nextAsyncEvent(context, currentEvent, nextEvent);
|
|
288
|
-
return undefined;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
const context = {
|
|
292
|
-
eventIndex: 0,
|
|
293
|
-
allEventsOnSameElement: eventData.allEventsOnSameElement,
|
|
294
|
-
events: eventData.events,
|
|
295
|
-
eventType: eventData.eventType,
|
|
296
|
-
eventData: eventData.eventData,
|
|
297
|
-
stepId: eventData.id,
|
|
298
|
-
testResultId: eventData.testResultId,
|
|
299
|
-
isDrag: eventData.isDrag,
|
|
300
|
-
useRecordedMousedown: eventData.useRecordedMousedown,
|
|
301
|
-
trackActiveElement: eventData.trackActiveElement,
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
setTimeout(() => {
|
|
305
|
-
try {
|
|
306
|
-
executeAsyncNext(context);
|
|
307
|
-
} catch (err) {
|
|
308
|
-
reject(err);
|
|
309
|
-
}
|
|
310
|
-
}, 0);
|
|
311
|
-
};
|
|
312
|
-
module.exports = html5dndAction;
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/* global getLocatedElement */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const runCode = function (eventData, preCompiledCode) {
|
|
6
|
-
function appendToStorage(name, data) {
|
|
7
|
-
const sessionItem = `data-testim-${name}`;
|
|
8
|
-
|
|
9
|
-
const nativeFuncErrMsg = 'Native sessionStorage is not available';
|
|
10
|
-
function isNativeFunction(fn) {
|
|
11
|
-
if (!fn?.toString) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
return fn.toString().includes('[native code]');
|
|
15
|
-
}
|
|
16
|
-
try {
|
|
17
|
-
if (![window.sessionStorage.setItem, window.sessionStorage.getItem].every(isNativeFunction)) {
|
|
18
|
-
throw new Error(nativeFuncErrMsg);
|
|
19
|
-
}
|
|
20
|
-
const oldData = JSON.parse(window.sessionStorage.getItem(sessionItem) || '{}');
|
|
21
|
-
const newData = Object.assign({}, oldData, data);
|
|
22
|
-
window.sessionStorage.setItem(sessionItem, JSON.stringify(newData));
|
|
23
|
-
} catch (err) {
|
|
24
|
-
// any variation QuotaExceededError from browsers
|
|
25
|
-
const isQuotaExceededError = err.message.toLowerCase().includes('quota');
|
|
26
|
-
const isNativeFunctionError = err.message === nativeFuncErrMsg;
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
err.message.includes('sessionStorage') || // Chrome + Firefox
|
|
30
|
-
err.message.includes('The operation is insecure') || // Safari
|
|
31
|
-
isQuotaExceededError ||
|
|
32
|
-
isNativeFunctionError
|
|
33
|
-
) {
|
|
34
|
-
let storage = document.head.querySelector('#testim-storage-backup');
|
|
35
|
-
if (!storage) {
|
|
36
|
-
storage = document.createElement('meta');
|
|
37
|
-
storage.id = 'testim-storage-backup';
|
|
38
|
-
document.head.append(storage);
|
|
39
|
-
}
|
|
40
|
-
const oldData = JSON.parse(storage.getAttribute(sessionItem) || '{}');
|
|
41
|
-
const newData = Object.assign({}, oldData, data);
|
|
42
|
-
storage.setAttribute(sessionItem, JSON.stringify(newData));
|
|
43
|
-
if (isQuotaExceededError || isNativeFunctionError) {
|
|
44
|
-
try {
|
|
45
|
-
window.sessionStorage.removeItem(sessionItem);
|
|
46
|
-
} catch (e) {
|
|
47
|
-
// Prevents future retries from looking in sessionStorage with old data
|
|
48
|
-
}
|
|
49
|
-
(window.TSTA = window.TSTA || {}).useFallbackStorage = true;
|
|
50
|
-
}
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
throw err;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function getExecutionArguments(eventData) {
|
|
58
|
-
// New code with stepParamsBuilder
|
|
59
|
-
if (eventData.function) {
|
|
60
|
-
return eventData.function.args
|
|
61
|
-
.map((arg) => (arg?.locatedElement ? getLocatedElement(arg.locatedElement) : arg));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Old code
|
|
65
|
-
return eventData.directParams
|
|
66
|
-
.map((p) => (p.selector ? document.querySelector(p.selector) : p.value))
|
|
67
|
-
.concat(eventData.otherParams);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function constructWithArguments(constructor, args) {
|
|
71
|
-
function F() {
|
|
72
|
-
return constructor.apply(this, args);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
F.prototype = constructor.prototype;
|
|
76
|
-
return new F();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const exportedData = {};
|
|
80
|
-
const exportedTestData = {};
|
|
81
|
-
const exportedGlobalData = {};
|
|
82
|
-
|
|
83
|
-
const functionParams = eventData.functionParams;
|
|
84
|
-
const transactionId = eventData.transactionId;
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
const args = getExecutionArguments(eventData);
|
|
88
|
-
|
|
89
|
-
args.push(exportedData, exportedTestData, exportedGlobalData);
|
|
90
|
-
|
|
91
|
-
const params = eventData.function?.params || functionParams;
|
|
92
|
-
|
|
93
|
-
const functionToRun = preCompiledCode || constructWithArguments(Function, params);
|
|
94
|
-
const result = functionToRun.apply(null, args);
|
|
95
|
-
|
|
96
|
-
if (typeof Promise !== 'undefined' && result instanceof Promise) {
|
|
97
|
-
appendToStorage(transactionId, { type: 'promise' });
|
|
98
|
-
result.then((res) => {
|
|
99
|
-
appendToStorage(transactionId, {
|
|
100
|
-
status: 'done',
|
|
101
|
-
success: true,
|
|
102
|
-
result: {
|
|
103
|
-
resultValue: res,
|
|
104
|
-
exports: exportedData,
|
|
105
|
-
exportsTest: exportedTestData,
|
|
106
|
-
exportsGlobal: exportedGlobalData,
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
}, (res) => {
|
|
110
|
-
appendToStorage(transactionId, {
|
|
111
|
-
status: 'failed',
|
|
112
|
-
success: false,
|
|
113
|
-
result: {
|
|
114
|
-
resultValue: res.toString(),
|
|
115
|
-
exports: exportedData,
|
|
116
|
-
exportsTest: exportedTestData,
|
|
117
|
-
exportsGlobal: exportedGlobalData,
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
} else {
|
|
122
|
-
appendToStorage(transactionId, {
|
|
123
|
-
status: 'done',
|
|
124
|
-
success: true,
|
|
125
|
-
result: {
|
|
126
|
-
resultValue: result,
|
|
127
|
-
exports: exportedData,
|
|
128
|
-
exportsTest: exportedTestData,
|
|
129
|
-
exportsGlobal: exportedGlobalData,
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
} catch (e) {
|
|
134
|
-
appendToStorage(transactionId, {
|
|
135
|
-
status: 'failed',
|
|
136
|
-
success: false,
|
|
137
|
-
result: {
|
|
138
|
-
resultValue: e.toString(),
|
|
139
|
-
exports: exportedData,
|
|
140
|
-
exportsTest: exportedTestData,
|
|
141
|
-
exportsGlobal: exportedGlobalData,
|
|
142
|
-
},
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
module.exports = runCode;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/* globals getLocatedElement, elementScrollTo */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const scroll = function (elementToScrollOn, elementToScrollTo, isScrollToElement, isDynamicScroll, expectedX, expectedY, shouldScrollLeft, shouldScrollTop) {
|
|
6
|
-
function doScroll(expectedPosition, element) {
|
|
7
|
-
if (!element) {
|
|
8
|
-
return { success: false };
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
elementScrollTo(element, expectedPosition.x, expectedPosition.y);
|
|
12
|
-
|
|
13
|
-
const actualX = element.scrollLeft;
|
|
14
|
-
const actualY = element.scrollTop;
|
|
15
|
-
|
|
16
|
-
const success = (Math.abs(actualY - expectedPosition.y) < 1) && (Math.abs(actualX - expectedPosition.x) < 1);
|
|
17
|
-
return { success, actualX, actualY };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function getExpectedPosition(parentElement, locatedElement, isScrollToElement, expectedX, expectedY, shouldScrollLeft, shouldScrollTop) {
|
|
21
|
-
if (!isScrollToElement) {
|
|
22
|
-
return { x: expectedX, y: expectedY };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const target = getLocatedElement(locatedElement);
|
|
26
|
-
|
|
27
|
-
if (isDynamicScroll && !target) {
|
|
28
|
-
return { x: parentElement.scrollWidth, y: parentElement.scrollHeight };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (!target) {
|
|
32
|
-
throw new Error('could not find target element');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const targetRect = target.getBoundingClientRect();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
let yScroll = 0;
|
|
39
|
-
let xScroll = 0;
|
|
40
|
-
const MAX_HEIGHT = Math.max(window.innerHeight - (targetRect.height + 10), 0);
|
|
41
|
-
const MAX_WIDTH = Math.max(window.innerWidth - (targetRect.width + 10), 0);
|
|
42
|
-
|
|
43
|
-
yScroll = shouldScrollTop ?
|
|
44
|
-
parentElement.scrollTop + targetRect.top - Math.min(expectedY, MAX_HEIGHT) :
|
|
45
|
-
parentElement.scrollTop;
|
|
46
|
-
|
|
47
|
-
xScroll = shouldScrollLeft ?
|
|
48
|
-
parentElement.scrollLeft + targetRect.left - Math.min(expectedX, MAX_WIDTH) :
|
|
49
|
-
parentElement.scrollLeft;
|
|
50
|
-
|
|
51
|
-
return { x: Math.round(xScroll), y: Math.round(yScroll) };
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const isDocument = !elementToScrollOn;
|
|
55
|
-
elementToScrollOn = !isDocument ? getLocatedElement(elementToScrollOn) : (document.scrollingElement || document.documentElement);
|
|
56
|
-
|
|
57
|
-
if (!elementToScrollOn) {
|
|
58
|
-
throw new Error('could not find target to scroll on');
|
|
59
|
-
}
|
|
60
|
-
const positionBeforeScroll = { top: elementToScrollOn.scrollTop, left: elementToScrollOn.scrollLeft };
|
|
61
|
-
let expectedPosition = getExpectedPosition(elementToScrollOn, elementToScrollTo, isScrollToElement, expectedX, expectedY, shouldScrollLeft, shouldScrollTop);
|
|
62
|
-
|
|
63
|
-
let result = doScroll(expectedPosition, elementToScrollOn);
|
|
64
|
-
|
|
65
|
-
if (isDocument && (!document.scrollingElement) && (!result.success) && (positionBeforeScroll.top === elementToScrollOn.scrollTop) && (positionBeforeScroll.left === elementToScrollOn.scrollLeft)) {
|
|
66
|
-
elementToScrollOn = document.body;
|
|
67
|
-
expectedPosition = getExpectedPosition(elementToScrollOn, elementToScrollTo, isScrollToElement, expectedX, expectedY, shouldScrollLeft, shouldScrollTop);
|
|
68
|
-
result = doScroll(expectedPosition, elementToScrollOn);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
let actualXString = result.actualX;
|
|
72
|
-
let actualYString = result.actualY;
|
|
73
|
-
const actualScrollToElement = getLocatedElement(elementToScrollTo);
|
|
74
|
-
|
|
75
|
-
if (isScrollToElement && isDynamicScroll && !actualScrollToElement) {
|
|
76
|
-
return { success: false, expectedPosition };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (isScrollToElement) {
|
|
80
|
-
if (!actualScrollToElement) {
|
|
81
|
-
throw new Error('could not find target to scroll to');
|
|
82
|
-
}
|
|
83
|
-
const rect = actualScrollToElement.getBoundingClientRect();
|
|
84
|
-
actualXString = rect.left;
|
|
85
|
-
actualYString = rect.top;
|
|
86
|
-
}
|
|
87
|
-
return { success: result.success, actualX: actualXString, actualY: actualYString };
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
module.exports = scroll;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-restricted-syntax */ // This code only runs in Safari, not in IE.
|
|
2
|
-
module.exports = function (locatedElement, dispatchEventOnSelectElement) {
|
|
3
|
-
function closest(el, selectors) {
|
|
4
|
-
const originalMatches = Element.prototype.matches;
|
|
5
|
-
/* eslint-disable-next-line no-proto, no-undef */ // Some customers override the native Element prototype, so we need to create a new one if they messed it up.
|
|
6
|
-
const matches = originalMatches && isNativeFunction(originalMatches) ? originalMatches : document.createElement(el.tagName).__proto__.matches;
|
|
7
|
-
do {
|
|
8
|
-
if (matches.call(el, selectors)) return el;
|
|
9
|
-
el = el.parentElement || el.parentNode;
|
|
10
|
-
} while (el !== null && el.nodeType === 1);
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
/* eslint-disable-next-line no-undef */ // This code depends on pre-injecting this function as well.
|
|
16
|
-
const optionEl = getLocatedElement(locatedElement);
|
|
17
|
-
if (!optionEl) {
|
|
18
|
-
return { success: false, status: 'failed', result: 'option element not found' };
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const selectEl = closest(optionEl, 'select');
|
|
22
|
-
if (!selectEl) {
|
|
23
|
-
return { success: false, status: 'failed', result: 'select element not found' };
|
|
24
|
-
}
|
|
25
|
-
selectEl.focus();
|
|
26
|
-
if (optionEl.selected) {
|
|
27
|
-
return { success: true, status: 'done' };
|
|
28
|
-
}
|
|
29
|
-
optionEl.selected = true;
|
|
30
|
-
|
|
31
|
-
const events = [
|
|
32
|
-
'input',
|
|
33
|
-
'change',
|
|
34
|
-
];
|
|
35
|
-
events.map((userEvent) => {
|
|
36
|
-
const event = document.createEvent('HTMLEvents');
|
|
37
|
-
event.initEvent(userEvent, true, false);
|
|
38
|
-
return event;
|
|
39
|
-
}).forEach((event) => {
|
|
40
|
-
if (dispatchEventOnSelectElement) {
|
|
41
|
-
selectEl.dispatchEvent(event);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
optionEl.dispatchEvent(event);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return { success: true, status: 'done' };
|
|
48
|
-
} catch (err) {
|
|
49
|
-
return { success: false, status: 'failed', result: err.toString() };
|
|
50
|
-
}
|
|
51
|
-
};
|