@testim/testim-cli 3.289.0 → 3.290.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 +22390 -122
- package/cli.js.map +1 -0
- package/npm-shrinkwrap.json +1951 -203
- package/package.json +9 -5
- 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,415 +0,0 @@
|
|
|
1
|
-
/* globals getLocatedElement, dispatchFocus */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const setText = function (eventData, done) {
|
|
6
|
-
const eventConstructorSupported = typeof Event === 'function';
|
|
7
|
-
const element = eventData.isRoot ? document.documentElement : getLocatedElement(eventData.locatedElement);
|
|
8
|
-
const context = {
|
|
9
|
-
eventIndex: 0,
|
|
10
|
-
element,
|
|
11
|
-
events: eventData.events,
|
|
12
|
-
eventType: eventData.eventType,
|
|
13
|
-
quirks: eventData.quirks,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
if (!element) {
|
|
17
|
-
throw new Error('element not found');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
window.__unloadNavigator = function () {
|
|
21
|
-
resolve();
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
window.addEventListener('unload', window.__unloadNavigator);
|
|
25
|
-
|
|
26
|
-
const keyboardEventNames = ['keydown', 'keyup', 'keypress'];
|
|
27
|
-
const MAX_KEYBOARD_EVENT_TIMEOUT = 15; //max msec between keyboard events
|
|
28
|
-
|
|
29
|
-
function getTextInputEventObject(userEvent) {
|
|
30
|
-
try {
|
|
31
|
-
if (!eventConstructorSupported) {
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const event = new CustomEvent('textInput', {
|
|
36
|
-
bubbles: true,
|
|
37
|
-
cancelable: true,
|
|
38
|
-
});
|
|
39
|
-
if (userEvent.eventData) {
|
|
40
|
-
event.data = userEvent.eventData.data;
|
|
41
|
-
}
|
|
42
|
-
return event;
|
|
43
|
-
} catch (err) { /* ignored */ }
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function initTextInputEvent(userEvent) {
|
|
48
|
-
try {
|
|
49
|
-
const event = document.createEvent('TextEvent');
|
|
50
|
-
event.data = userEvent.eventData.data;
|
|
51
|
-
const method = 1; // keyboard
|
|
52
|
-
const locale = userEvent.eventData.locale || 'en-US';
|
|
53
|
-
event.initTextEvent('textInput', true, true, window, userEvent.eventData.data, method, locale);
|
|
54
|
-
return event;
|
|
55
|
-
} catch (err) { /* ignored */ }
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function getTextInputEvent(userEvent) {
|
|
60
|
-
return getTextInputEventObject(userEvent) || initTextInputEvent();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function createKeyboardEventObject(eventType, eventData, modifiers) {
|
|
64
|
-
try {
|
|
65
|
-
return new KeyboardEvent(eventType, {
|
|
66
|
-
bubbles: true,
|
|
67
|
-
cancelable: true,
|
|
68
|
-
location: eventData.location || 0,
|
|
69
|
-
key: eventData.key || '',
|
|
70
|
-
ctrlKey: Boolean(modifiers.ctrl),
|
|
71
|
-
shiftKey: Boolean(modifiers.shift),
|
|
72
|
-
altKey: Boolean(modifiers.alt),
|
|
73
|
-
metaKey: Boolean(modifiers.meta),
|
|
74
|
-
});
|
|
75
|
-
} catch (err) { /* ignored */ }
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function initKeyboardEvent(eventType, eventData, modifiers) {
|
|
80
|
-
try {
|
|
81
|
-
const event = document.createEvent('KeyboardEvent');
|
|
82
|
-
|
|
83
|
-
event.initKeyEvent(
|
|
84
|
-
eventType, // typeArg,
|
|
85
|
-
true, // canBubbleArg,
|
|
86
|
-
true, // cancelableArg,
|
|
87
|
-
null, // viewArg, Specifies UIEvent.view. This value may be null.
|
|
88
|
-
Boolean(modifiers.ctrl),
|
|
89
|
-
Boolean(modifiers.alt),
|
|
90
|
-
Boolean(modifiers.shift),
|
|
91
|
-
Boolean(modifiers.meta),
|
|
92
|
-
eventData.key || '',
|
|
93
|
-
0, // charCodeArg
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
return event;
|
|
97
|
-
} catch (err) { /* ignored */ }
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function createKeyboardEvents(eventType, eventData, modifiers) {
|
|
102
|
-
try {
|
|
103
|
-
const event = document.createEvent('Events');
|
|
104
|
-
event.initEvent(eventType, true, true);
|
|
105
|
-
event.altKey = Boolean(modifiers.alt);
|
|
106
|
-
event.ctrlKey = Boolean(modifiers.ctrl);
|
|
107
|
-
event.metaKey = Boolean(modifiers.meta);
|
|
108
|
-
event.shiftKey = Boolean(modifiers.shift);
|
|
109
|
-
event.keyCode = eventData.key || '';
|
|
110
|
-
return event;
|
|
111
|
-
} catch (err) { /* ignored */ }
|
|
112
|
-
return undefined;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function createKeyboardEvent(eventType, eventData, modifiers) {
|
|
116
|
-
return createKeyboardEventObject(eventType, eventData, modifiers) ||
|
|
117
|
-
initKeyboardEvent(eventType, eventData, modifiers) ||
|
|
118
|
-
createKeyboardEvents(eventType, eventData, modifiers);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function getKeyboardEvent(userEvent) {
|
|
122
|
-
// some apps override Array.indexOf to return undefined if element not found (like Arkia)
|
|
123
|
-
const index = keyboardEventNames.indexOf(userEvent.event);
|
|
124
|
-
if ((typeof index !== 'number') || (index < 0)) {
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const eventData = userEvent.eventData;
|
|
129
|
-
const modifiers = eventData.modifiers || {};
|
|
130
|
-
|
|
131
|
-
const event = createKeyboardEvent(userEvent.event, eventData, modifiers);
|
|
132
|
-
|
|
133
|
-
// workaround for chromium bugs which make keycode etc readonly
|
|
134
|
-
Object.defineProperties(event, {
|
|
135
|
-
keyCode: {
|
|
136
|
-
enumerable: true,
|
|
137
|
-
get() {
|
|
138
|
-
return this._keyCode_;
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
charCode: {
|
|
142
|
-
enumerable: true,
|
|
143
|
-
get() {
|
|
144
|
-
return this._charCode_;
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
which: {
|
|
148
|
-
enumerable: true,
|
|
149
|
-
get() {
|
|
150
|
-
return this._keyCode_;
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
event._keyCode_ = eventData.keyCode;
|
|
155
|
-
event._charCode_ = eventData.charCode || 0;
|
|
156
|
-
return event;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function getEvent(userEvent) {
|
|
160
|
-
return userEvent.event === 'textInput' ?
|
|
161
|
-
getTextInputEvent(userEvent) :
|
|
162
|
-
getKeyboardEvent(userEvent);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function shouldSkipEvent(currentEvent, context) {
|
|
166
|
-
const isTextInputAuth0Form = function () {
|
|
167
|
-
return currentEvent.event === 'textInput' && !context.quirks?.isAuth0Form;
|
|
168
|
-
};
|
|
169
|
-
return isTextInputAuth0Form();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function getTextEventTimeout(currentEvent, nextEvent) {
|
|
173
|
-
return ((currentEvent.event === 'keyup') && (nextEvent.event === 'keydown')) ?
|
|
174
|
-
MAX_KEYBOARD_EVENT_TIMEOUT :
|
|
175
|
-
0;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function getTimeBetweenFiringEvents(context, currentEvent, nextEvent) {
|
|
179
|
-
const maxTimeout = getTextEventTimeout(currentEvent, nextEvent);
|
|
180
|
-
return Math.min(nextEvent.timeStamp - currentEvent.timeStamp, maxTimeout);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function handleReactFormFocus(element) {
|
|
184
|
-
// solution taken partially from https://github.com/vitalyq/react-trigger-change
|
|
185
|
-
const descriptor = Object.getOwnPropertyDescriptor(element, 'value');
|
|
186
|
-
if (!descriptor) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
const initialValue = element.value;
|
|
190
|
-
element.value = `${initialValue}#`;
|
|
191
|
-
if (descriptor.configurable) {
|
|
192
|
-
delete element.value;
|
|
193
|
-
}
|
|
194
|
-
element.value = initialValue;
|
|
195
|
-
const event = document.createEvent('HTMLEvents');
|
|
196
|
-
event.initEvent('input', true, false);
|
|
197
|
-
element.dispatchEvent(event);
|
|
198
|
-
Object.defineProperty(element, 'value', descriptor);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function handleChangeEventIfNeeded(context) {
|
|
202
|
-
if (!context.isInput) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
try {
|
|
206
|
-
handleReactFormFocus(context.element);
|
|
207
|
-
if (eventConstructorSupported) {
|
|
208
|
-
context.element.dispatchEvent(new Event('change'));
|
|
209
|
-
} else {
|
|
210
|
-
const event = document.createEvent('HTMLEvents');
|
|
211
|
-
event.initEvent('change', false, true);
|
|
212
|
-
context.element.dispatchEvent(event);
|
|
213
|
-
}
|
|
214
|
-
} catch (e) { /* ignored */ }
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function nextAsyncEvent(context, currentEvent, nextEvent) {
|
|
218
|
-
if (nextEvent) {
|
|
219
|
-
setTimeout(() => {
|
|
220
|
-
executeAsyncNext(context);
|
|
221
|
-
}, getTimeBetweenFiringEvents(context, currentEvent, nextEvent));
|
|
222
|
-
} else {
|
|
223
|
-
if (window.__unloadNavigator) {
|
|
224
|
-
window.removeEventListener('unload', window.__unloadNavigator);
|
|
225
|
-
}
|
|
226
|
-
handleChangeEventIfNeeded(context);
|
|
227
|
-
resolve();
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function shouldDispatchOnParentElement(eventType, context) {
|
|
232
|
-
return (eventType === 'change' || eventType === 'blur') && context.element.tagName === 'OPTION';
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function getElement(event, context, currentEvent) {
|
|
236
|
-
if (shouldDispatchOnParentElement(event.type, context)) {
|
|
237
|
-
return context.element.parentElement;
|
|
238
|
-
} if (currentEvent.locatedElement) {
|
|
239
|
-
return getLocatedElement(currentEvent.locatedElement);
|
|
240
|
-
}
|
|
241
|
-
return context.element;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function findTextNode(element, offsetData) {
|
|
245
|
-
let child = element.firstChild;
|
|
246
|
-
let innerChild;
|
|
247
|
-
while (child) {
|
|
248
|
-
if (child.nodeType === 3) {
|
|
249
|
-
if (offsetData.offset-- <= 0) {
|
|
250
|
-
return child;
|
|
251
|
-
}
|
|
252
|
-
} else if (child.nodeType === 1) {
|
|
253
|
-
innerChild = findTextNode(child, offsetData);
|
|
254
|
-
if (innerChild) {
|
|
255
|
-
return innerChild;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
child = child.nextSibling;
|
|
259
|
-
}
|
|
260
|
-
return null;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function setSelection(element, selection) {
|
|
264
|
-
if (!element || !selection) {
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
// eslint-disable-next-line no-restricted-globals
|
|
268
|
-
if (!isNaN(selection.start)) {
|
|
269
|
-
element.selectionStart = selection.start;
|
|
270
|
-
element.selectionEnd = selection.end;
|
|
271
|
-
// eslint-disable-next-line no-restricted-globals
|
|
272
|
-
} else if (!isNaN(selection.nodeOffset)) {
|
|
273
|
-
let startNode;
|
|
274
|
-
if (element.firstChild) {
|
|
275
|
-
startNode = findTextNode(element, { offset: selection.nodeOffset });
|
|
276
|
-
} else {
|
|
277
|
-
startNode = element;
|
|
278
|
-
}
|
|
279
|
-
if (startNode) {
|
|
280
|
-
const sel = window.getSelection();
|
|
281
|
-
const range = document.createRange();
|
|
282
|
-
|
|
283
|
-
try { // until we get our act together regarding contenteditable, this may throw when the numbers in the recorded data don't match the current text
|
|
284
|
-
sel.removeAllRanges();
|
|
285
|
-
range.setStart(startNode, selection.textOffset);
|
|
286
|
-
range.setEnd(startNode, selection.textOffset);
|
|
287
|
-
sel.addRange(range);
|
|
288
|
-
} catch (ignore) { /* ignored */ }
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function executeAsyncEvent(event, context, currentEvent) {
|
|
294
|
-
if (context.isFocusable && context.isSelectable(event) && event.type !== 'submit') {
|
|
295
|
-
try {
|
|
296
|
-
setSelection(context.element, currentEvent.eventData.selection);
|
|
297
|
-
} catch (ignore) { /* ignored */ }
|
|
298
|
-
}
|
|
299
|
-
const element = getElement(event, context, currentEvent);
|
|
300
|
-
if (!element) {
|
|
301
|
-
throw new Error('could not find element');
|
|
302
|
-
}
|
|
303
|
-
if (event.type === 'submit' && element.action) {
|
|
304
|
-
element.submit();
|
|
305
|
-
} else {
|
|
306
|
-
element.dispatchEvent(event);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
function executeAsyncNext(context) {
|
|
311
|
-
let event;
|
|
312
|
-
const currentEvent = context.events[context.eventIndex];
|
|
313
|
-
const nextEvent = context.events[++context.eventIndex];
|
|
314
|
-
try {
|
|
315
|
-
event = getEvent(currentEvent);
|
|
316
|
-
} catch (err) {
|
|
317
|
-
return reject(`exception in get event in text step:${err.message}`);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
if (shouldSkipEvent(currentEvent, context)) {
|
|
321
|
-
return nextAsyncEvent(context, currentEvent, nextEvent);
|
|
322
|
-
} if (event) {
|
|
323
|
-
try {
|
|
324
|
-
executeAsyncEvent(event, context, currentEvent);
|
|
325
|
-
} catch (err) {
|
|
326
|
-
return reject(`exception in executeEvent in text step:${err.message}`);
|
|
327
|
-
}
|
|
328
|
-
} else if (context.noEventExecuter) {
|
|
329
|
-
context.noEventExecuter(context, currentEvent);
|
|
330
|
-
} else {
|
|
331
|
-
return reject(`cannot execute event ${currentEvent.event}`);
|
|
332
|
-
}
|
|
333
|
-
nextAsyncEvent(context, currentEvent, nextEvent);
|
|
334
|
-
return undefined;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
function isFocusableInput(target) {
|
|
338
|
-
const tagName = target.tagName;
|
|
339
|
-
return (tagName === 'INPUT' || tagName === 'TEXTAREA');
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
function isContentEditable(target) {
|
|
343
|
-
return target.getAttribute ?
|
|
344
|
-
Boolean(target.getAttribute('contenteditable') === 'true') :
|
|
345
|
-
false;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function executeSetValue(context, userEvent) {
|
|
349
|
-
if (context.isInput) {
|
|
350
|
-
context.element.value = userEvent.eventData.text;
|
|
351
|
-
const inputEvent = document.createEvent('Event');
|
|
352
|
-
inputEvent.initEvent('input', true, false);
|
|
353
|
-
context.element.dispatchEvent(inputEvent);
|
|
354
|
-
} else if (context.isContentEditable) {
|
|
355
|
-
context.element.innerHTML = userEvent.eventData.text;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
function findEffectiveActiveElement() {
|
|
360
|
-
let activeElement = document.activeElement;
|
|
361
|
-
while (activeElement.shadowRoot?.activeElement) {
|
|
362
|
-
activeElement = activeElement.shadowRoot.activeElement;
|
|
363
|
-
}
|
|
364
|
-
return activeElement;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
function resolve(result) {
|
|
368
|
-
const status = {
|
|
369
|
-
status: 'done',
|
|
370
|
-
result,
|
|
371
|
-
success: true,
|
|
372
|
-
};
|
|
373
|
-
if (context.isNonTextableElemnet) {
|
|
374
|
-
status.reason = 'Set text on non input element';
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
done(status);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
function reject(result) {
|
|
381
|
-
result = result || {};
|
|
382
|
-
const status = {
|
|
383
|
-
status: 'failed',
|
|
384
|
-
result,
|
|
385
|
-
success: false,
|
|
386
|
-
};
|
|
387
|
-
if (context.isNonTextableElemnet) {
|
|
388
|
-
status.reason = 'Set text on non input element';
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
done(status);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
try {
|
|
395
|
-
context.isInput = isFocusableInput(context.element);
|
|
396
|
-
context.isContentEditable = isContentEditable(context.element);
|
|
397
|
-
if (!context.isInput && !context.isContentEditable) {
|
|
398
|
-
context.isNonTextableElemnet = true;
|
|
399
|
-
}
|
|
400
|
-
context.isFocusable = context.isInput || context.isContentEditable;
|
|
401
|
-
context.isSelectable = function (event) {
|
|
402
|
-
return event.type !== 'keyup';
|
|
403
|
-
};
|
|
404
|
-
context.noEventExecuter = executeSetValue;
|
|
405
|
-
} catch (err) {
|
|
406
|
-
reject(`exception in set text step:${err.message}`);
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
const oldActiveElement = findEffectiveActiveElement();
|
|
411
|
-
dispatchFocus(eventData.elementToFocusLocatedElement, oldActiveElement);
|
|
412
|
-
executeAsyncNext(context);
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
module.exports = setText;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/* global getLocatedElement */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const wheel = function (eventData, done) {
|
|
6
|
-
const MAX_WHEEL_EVENT_TIMEOUT = 200;
|
|
7
|
-
|
|
8
|
-
function getEventPosition(userEvent, element) {
|
|
9
|
-
function isWithinBounds(start, end, point) {
|
|
10
|
-
return (point > start) && (point < end);
|
|
11
|
-
}
|
|
12
|
-
const pointerPosition = userEvent.pointerPosition || {};
|
|
13
|
-
const rect = element.getBoundingClientRect();
|
|
14
|
-
const clientX = pointerPosition.originX && isWithinBounds(rect.left, rect.left + rect.width, pointerPosition.originX) ? pointerPosition.originX : rect.left + (rect.width / 2);
|
|
15
|
-
const clientY = pointerPosition.originY && isWithinBounds(rect.top, rect.top + rect.height, pointerPosition.originY) ? pointerPosition.originY : rect.top + (rect.height / 2);
|
|
16
|
-
return { x: clientX, y: clientY };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function getWheelEvent(userEvent, eventData, element) {
|
|
20
|
-
const pos = getEventPosition(userEvent, element);
|
|
21
|
-
const modifiers = eventData?.modifiers || {};
|
|
22
|
-
const dict = {
|
|
23
|
-
deltaX: userEvent.deltaX,
|
|
24
|
-
deltaY: userEvent.deltaY,
|
|
25
|
-
deltaZ: userEvent.deltaZ,
|
|
26
|
-
deltaMode: userEvent.deltaMode,
|
|
27
|
-
clientX: pos.x,
|
|
28
|
-
clientY: pos.y,
|
|
29
|
-
bubbles: true,
|
|
30
|
-
cancelable: true,
|
|
31
|
-
ctrl: Boolean(modifiers.ctrl),
|
|
32
|
-
alt: Boolean(modifiers.alt),
|
|
33
|
-
shift: Boolean(modifiers.shift),
|
|
34
|
-
meta: Boolean(modifiers.meta),
|
|
35
|
-
};
|
|
36
|
-
return new WheelEvent('wheel', dict);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function executeEvents(events, element) {
|
|
40
|
-
if (events.length === 0) {
|
|
41
|
-
done({ state: 'success' });
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (!element) {
|
|
45
|
-
throw new Error('element not found');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const event = events.shift();
|
|
49
|
-
const currentEvent = getWheelEvent(event, eventData.eventData, element);
|
|
50
|
-
const timeout = events[0] ? Math.min(events[0].timeStamp - event.timeStamp, MAX_WHEEL_EVENT_TIMEOUT) : MAX_WHEEL_EVENT_TIMEOUT;
|
|
51
|
-
element.dispatchEvent(currentEvent);
|
|
52
|
-
setTimeout(() => {
|
|
53
|
-
executeEvents(events, element);
|
|
54
|
-
}, timeout);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const element = getLocatedElement(eventData.locatedElement);
|
|
58
|
-
executeEvents(eventData.events, element);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
module.exports = wheel;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const scroll = require('./scripts/scroll');
|
|
4
|
-
const StepAction = require('./stepAction');
|
|
5
|
-
|
|
6
|
-
class ScrollStepAction extends StepAction {
|
|
7
|
-
getFailureString(step, expectedX, expectedY, actualX, actualY) {
|
|
8
|
-
if (!step.isScrollToElement) {
|
|
9
|
-
return `Scrolling limit reached. Expected:(y: ${expectedY}, x: ${expectedX}); Actual:(y:${actualY}, x: ${actualX})`;
|
|
10
|
-
}
|
|
11
|
-
let failureMessage = 'Scrolling limit reached';
|
|
12
|
-
if (step.shouldScrollTop) {
|
|
13
|
-
failureMessage += `. Expected top margin: ${expectedY}, actual: ${actualY}`;
|
|
14
|
-
}
|
|
15
|
-
if (step.shouldScrollLeft) {
|
|
16
|
-
failureMessage += `. Expected left margin: ${expectedX}, actual: ${actualX}`;
|
|
17
|
-
}
|
|
18
|
-
return failureMessage;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async scroll(elementToScrollTo, step, elementToScrollOn) {
|
|
22
|
-
const { codeSnippets, commonConstants: { stepResult } } = this.sessionPlayerInit;
|
|
23
|
-
const expectedY = Math.round(Number(step.isScrollToElement ? step.marginTop : step.y));
|
|
24
|
-
const expectedX = Math.round(Number(step.isScrollToElement ? step.marginLeft : step.x));
|
|
25
|
-
|
|
26
|
-
// in Firefox setting scrollTop and scrollLeft propeties simultaneously takes only the lates,
|
|
27
|
-
const elementScrollTo = this.driver.isFirefox() ? function (element, x, y) {
|
|
28
|
-
element.scrollTo(x, y);
|
|
29
|
-
} : function (element, x, y) {
|
|
30
|
-
element.scrollTop = y;
|
|
31
|
-
element.scrollLeft = x;
|
|
32
|
-
};
|
|
33
|
-
const scrollCode = `
|
|
34
|
-
var getLocatedElement = ${codeSnippets.getLocatedElementCode};
|
|
35
|
-
var elementScrollTo = ${elementScrollTo.toString()};
|
|
36
|
-
var scroll = ${scroll.toString()};
|
|
37
|
-
return scroll.apply(null, arguments)
|
|
38
|
-
`;
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
const res = await this.driver.executeJSWithArray(scrollCode, [
|
|
42
|
-
elementToScrollOn,
|
|
43
|
-
elementToScrollTo,
|
|
44
|
-
Boolean(step.isScrollToElement),
|
|
45
|
-
Boolean(step.isDynamicScroll),
|
|
46
|
-
expectedX,
|
|
47
|
-
expectedY,
|
|
48
|
-
step.shouldScrollLeft,
|
|
49
|
-
step.shouldScrollTop,
|
|
50
|
-
]);
|
|
51
|
-
if (!res?.value) {
|
|
52
|
-
return {
|
|
53
|
-
errorType: stepResult.SCROLL_ACTION_FAILURE,
|
|
54
|
-
success: false,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const { success, actualX, actualY } = res.value;
|
|
59
|
-
|
|
60
|
-
if (success) {
|
|
61
|
-
return { success: true };
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
errorType: stepResult.SCROLL_ACTION_FAILURE,
|
|
66
|
-
success: false,
|
|
67
|
-
resultInfo: { error: this.getFailureString(step, expectedX, expectedY, actualX, actualY) },
|
|
68
|
-
};
|
|
69
|
-
} catch (error) {
|
|
70
|
-
return {
|
|
71
|
-
errorType: stepResult.SCROLL_ACTION_FAILURE,
|
|
72
|
-
success: false,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
scrollOnDocument(step, elementToScrollTo) {
|
|
78
|
-
return this.scroll(elementToScrollTo, step);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
scrollOnElement(step, elementToScrollTo) {
|
|
82
|
-
return this.scroll(elementToScrollTo, step, this.getTarget().locatedElement);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
execute() {
|
|
86
|
-
const context = this.context;
|
|
87
|
-
const step = this.step;
|
|
88
|
-
const elementToScrollTo = step.isScrollToElement ? context.data.scrollToElement.locatedElement : null;
|
|
89
|
-
|
|
90
|
-
return step.element.isDocument ?
|
|
91
|
-
this.scrollOnDocument(step, elementToScrollTo) :
|
|
92
|
-
this.scrollOnElement(step, elementToScrollTo);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
module.exports = ScrollStepAction;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const StepAction = require('./stepAction');
|
|
4
|
-
const selectOption = require('./scripts/selectOption');
|
|
5
|
-
const featureFlags = require('../../commons/featureFlags');
|
|
6
|
-
const { extractElementId } = require('../../utils');
|
|
7
|
-
|
|
8
|
-
class SelectOptionStepAction extends StepAction {
|
|
9
|
-
async performAction() {
|
|
10
|
-
const target = this.context.data[this.step.targetId || 'targetId'];
|
|
11
|
-
const { seleniumElement, locatedElement } = target;
|
|
12
|
-
|
|
13
|
-
const browserAndOS = await this.driver.getBrowserAndOS();
|
|
14
|
-
|
|
15
|
-
const browserMajor = browserAndOS.browserMajor;
|
|
16
|
-
const isSafari = this.driver.isSafari();
|
|
17
|
-
const isShadowed = Boolean(this.step.element?.isShadowed);
|
|
18
|
-
|
|
19
|
-
// TODO: Remove the special handling for safari < 12 after we upgrade our grid to safari 13.
|
|
20
|
-
// force use js code when element is shadow dom
|
|
21
|
-
if (!isSafari || (isSafari && browserMajor >= 13 && !isShadowed)) {
|
|
22
|
-
try {
|
|
23
|
-
const res = await this.driver.elementIdClick(extractElementId(seleniumElement));
|
|
24
|
-
return res;
|
|
25
|
-
} catch (err) {
|
|
26
|
-
// If customer overrides the native Element prototype, this click will fail for this reason. in such a case, fallback to use js code.
|
|
27
|
-
if (!err.message.includes('Cannot check the displayedness of a non-Element argument')) {
|
|
28
|
-
throw err;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const safariSelectOptionDispatchEventOnSelectElement = featureFlags.flags.safariSelectOptionDispatchEventOnSelectElement.isEnabled();
|
|
34
|
-
const selectOptionCode = `
|
|
35
|
-
var getLocatedElement = ${this.sessionPlayerInit.codeSnippets.getLocatedElementCode};
|
|
36
|
-
var isNativeFunction = ${this.sessionPlayerInit.utils.isNativeFunction.toString()};
|
|
37
|
-
var selectOption = ${selectOption.toString()};
|
|
38
|
-
return selectOption.apply(null, arguments);
|
|
39
|
-
`;
|
|
40
|
-
|
|
41
|
-
const result = await this.driver.executeJSWithArray(selectOptionCode, [locatedElement, safariSelectOptionDispatchEventOnSelectElement]);
|
|
42
|
-
if (result.value?.success) {
|
|
43
|
-
return { success: true };
|
|
44
|
-
}
|
|
45
|
-
return { success: false };
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
module.exports = SelectOptionStepAction;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const StepAction = require('./stepAction');
|
|
2
|
-
|
|
3
|
-
class SfdcRecordedStepAction extends StepAction {
|
|
4
|
-
async performAction() {
|
|
5
|
-
const { sfdc } = this.sessionPlayerInit;
|
|
6
|
-
const page = sfdc.sfdcNewSePage(this.driver, (level, message) => this.context.playback.sfdcAddLog(level, message));
|
|
7
|
-
page.log.info(`BEGIN STEP '${this.step.getStepPreview?.()}'`);
|
|
8
|
-
try {
|
|
9
|
-
const warnings = await sfdc.sfdcExecuteRecordedStep(page, this.step.recordedData, this.context);
|
|
10
|
-
return { success: true, reason: warnings };
|
|
11
|
-
} catch (err) {
|
|
12
|
-
return {
|
|
13
|
-
success: false,
|
|
14
|
-
reason: err.reason || err.message,
|
|
15
|
-
exception: err,
|
|
16
|
-
shouldRetry: false, // TODO - check this. Our (bFormat) steps are probably not retryable?
|
|
17
|
-
};
|
|
18
|
-
} finally {
|
|
19
|
-
page.releaseObjects();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = SfdcRecordedStepAction;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const StepAction = require('./stepAction');
|
|
2
|
-
|
|
3
|
-
class SfdcStepAction extends StepAction {
|
|
4
|
-
async performAction() {
|
|
5
|
-
const { sfdc } = this.sessionPlayerInit;
|
|
6
|
-
const page = sfdc.sfdcNewSePage(this.driver, (level, message) => this.context.playback.sfdcAddLog(level, message));
|
|
7
|
-
page.log.info(`BEGIN STEP '${this.step.getStepPreview?.()}'`);
|
|
8
|
-
try {
|
|
9
|
-
const actions = this.context.sfdcTestActions;
|
|
10
|
-
if (actions === undefined) {
|
|
11
|
-
throw new Error('No test actions were compiled');
|
|
12
|
-
}
|
|
13
|
-
const warnings = await sfdc.sfdcExecute(page, actions, this.context);
|
|
14
|
-
return { success: true, reason: warnings };
|
|
15
|
-
} catch (err) {
|
|
16
|
-
return {
|
|
17
|
-
success: false,
|
|
18
|
-
reason: err.reason || err.message,
|
|
19
|
-
exception: err,
|
|
20
|
-
shouldRetry: false, // TODO - check this. Our (bFormat) steps are probably not retryable?
|
|
21
|
-
};
|
|
22
|
-
} finally {
|
|
23
|
-
page.releaseObjects();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = SfdcStepAction;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const StepAction = require('./stepAction');
|
|
4
|
-
const { delay } = require('../../utils');
|
|
5
|
-
|
|
6
|
-
class SleepStepAction extends StepAction {
|
|
7
|
-
async performAction() {
|
|
8
|
-
await delay(this.step.durationMS);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
module.exports = SleepStepAction;
|