@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,199 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const StepAction = require('./stepAction');
|
|
4
|
-
const inputFileUtils = require('../../inputFileUtils');
|
|
5
|
-
const featureFlagService = require('../../commons/featureFlags');
|
|
6
|
-
const { getLogger } = require('../../commons/logger');
|
|
7
|
-
const { extractElementId, download } = require('../../utils');
|
|
8
|
-
|
|
9
|
-
const logger = getLogger('input-file-step-action');
|
|
10
|
-
|
|
11
|
-
class InputFileStepAction extends StepAction {
|
|
12
|
-
uploadFile(localFileLocation) {
|
|
13
|
-
return this.driver.uploadFile(localFileLocation);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
forceInputToBeVisible(target, visibleScriptOptions) {
|
|
17
|
-
logger.info('workaround - stepaction - move element to visible position');
|
|
18
|
-
|
|
19
|
-
const getVisibleElementCode = `
|
|
20
|
-
var getLocatedElement = ${this.sessionPlayerInit.codeSnippets.getLocatedElementCode};
|
|
21
|
-
var getVisibleElement = ${inputFileUtils.getVisibleElementScript(visibleScriptOptions)};
|
|
22
|
-
return getVisibleElement.apply(null, arguments);
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
return this.driver.executeJS(getVisibleElementCode, target.locatedElement);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async safariPreUploadActions(target) {
|
|
29
|
-
const options = {
|
|
30
|
-
width: '150px',
|
|
31
|
-
height: '150px',
|
|
32
|
-
left: '10px',
|
|
33
|
-
top: '10px',
|
|
34
|
-
};
|
|
35
|
-
try {
|
|
36
|
-
return await this.forceInputToBeVisible(target, options);
|
|
37
|
-
} catch (err) {
|
|
38
|
-
logger.error('failed to set input file in Safari recovery', { err });
|
|
39
|
-
throw err;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async uploadFilesAndForceVisibility(gridLocalFiles, target) {
|
|
44
|
-
try {
|
|
45
|
-
if (this.driver.isSafari()) {
|
|
46
|
-
await this.safariPreUploadActions(target);
|
|
47
|
-
}
|
|
48
|
-
await this.uploadFiles(gridLocalFiles, target);
|
|
49
|
-
} catch (err) {
|
|
50
|
-
const edgeErrorEditableMessage = 'The element is not editable';
|
|
51
|
-
const edgeErrorFocusableMessage = 'The element is not focusable';
|
|
52
|
-
const safariErrorVisibleMessage = 'An element command could not be completed because the element is not visible on the page.';
|
|
53
|
-
const elementNotInteractable = 'element not interactable';
|
|
54
|
-
const elementNotPointerOrKeyboardInteractable = 'element is not pointer- or keyboard interactable';
|
|
55
|
-
const invalidStateMsg = 'invalid element state: Element is not currently interactable and may not be manipulated';
|
|
56
|
-
const mustBeVisibleMsg = 'Element must not be hidden, disabled or read-only';
|
|
57
|
-
const notReachableByKeyboard = 'is not reachable by keyboard';
|
|
58
|
-
/** @type {string} */
|
|
59
|
-
const errorMsg = err ? err.message : '';
|
|
60
|
-
// Workaround move element if element is not visible or disabled
|
|
61
|
-
if (
|
|
62
|
-
errorMsg === invalidStateMsg ||
|
|
63
|
-
errorMsg.startsWith(mustBeVisibleMsg) ||
|
|
64
|
-
errorMsg.startsWith(edgeErrorEditableMessage) ||
|
|
65
|
-
errorMsg.startsWith(edgeErrorFocusableMessage) ||
|
|
66
|
-
errorMsg.startsWith(safariErrorVisibleMessage) ||
|
|
67
|
-
errorMsg.includes(notReachableByKeyboard) ||
|
|
68
|
-
errorMsg.includes(elementNotInteractable) ||
|
|
69
|
-
errorMsg.includes(elementNotPointerOrKeyboardInteractable)
|
|
70
|
-
) {
|
|
71
|
-
await this.forceInputToBeVisible(target);
|
|
72
|
-
await this.uploadFiles(gridLocalFiles, target);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
logger.error('failed to set input file', { err });
|
|
77
|
-
throw err;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async uploadFiles(gridLocalFiles, target) {
|
|
82
|
-
for (const file of gridLocalFiles) {
|
|
83
|
-
await this.driver.elementIdValue(extractElementId(target.seleniumElement), file);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async performAction() {
|
|
88
|
-
const target = this.context.data[this.step.targetId || 'targetId'];
|
|
89
|
-
const overrideAzureStorageUrl = featureFlagService.flags.overrideAzureStorageUrl.isEnabled();
|
|
90
|
-
const useJsInputCodeInSafari = featureFlagService.flags.useJsInputCodeInSafari.isEnabled();
|
|
91
|
-
const useJsInputCodeInFirefox = featureFlagService.flags.useJsInputCodeInFirefox.isEnabled();
|
|
92
|
-
const downloadToBase64 = featureFlagService.flags.downloadToBase64.isEnabled();
|
|
93
|
-
|
|
94
|
-
let fileUrls = await this.sessionPlayerInit.utils.addTokenToFileUrl(this.context.project.id, this.step.fileUrls, this.stepActionUtils.testimServicesApi, overrideAzureStorageUrl, logger);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const isSafariJsInputCode = this.driver.isSafari() && (useJsInputCodeInSafari || fileUrls.length > 1);
|
|
98
|
-
const isFirefoxJsInputCode = this.driver.isFirefox() && (useJsInputCodeInFirefox || fileUrls.length > 1);
|
|
99
|
-
|
|
100
|
-
if (downloadToBase64) {
|
|
101
|
-
fileUrls = await Promise.all(fileUrls.map(async ({ name, url }) => {
|
|
102
|
-
const res = await download(url);
|
|
103
|
-
return { name, url: `data:${res.type};base64,${Buffer.from(res.body).toString('base64')}` };
|
|
104
|
-
}));
|
|
105
|
-
}
|
|
106
|
-
if (isSafariJsInputCode || isFirefoxJsInputCode) {
|
|
107
|
-
await this.driver.executeJSWithArray(`
|
|
108
|
-
const getLocatedElement = ${this.sessionPlayerInit.codeSnippets.getLocatedElementCode};
|
|
109
|
-
const downloadAndUploadFile = ${downloadAndUpload()};
|
|
110
|
-
return downloadAndUploadFile.apply(null, arguments);`, [target.locatedElement, fileUrls]);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const gridLocalFiles = await inputFileUtils.downloadFilesAndUploadToGrid(fileUrls, this.uploadFile.bind(this));
|
|
115
|
-
await this.uploadFilesAndForceVisibility(gridLocalFiles, target);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
module.exports = InputFileStepAction;
|
|
120
|
-
function downloadAndUpload() {
|
|
121
|
-
return `async function downloadAndUpload(locatedElement, fileUrls) {
|
|
122
|
-
const fileIsNative = typeof window.File === 'function' && (window.File.toString().indexOf('native code') > -1);
|
|
123
|
-
const File = fileIsNative ? window.File : (function obtainSafeGlobals() {
|
|
124
|
-
const attachTo = document.body || document.documentElement;
|
|
125
|
-
if (attachTo) {
|
|
126
|
-
let tempIFrame;
|
|
127
|
-
try {
|
|
128
|
-
tempIFrame = document.createElement('iframe');
|
|
129
|
-
tempIFrame.style.setProperty('display', 'none');
|
|
130
|
-
tempIFrame.style.setProperty('pointer-events', 'none');
|
|
131
|
-
attachTo.appendChild(tempIFrame);
|
|
132
|
-
const { File } = tempIFrame.contentWindow;
|
|
133
|
-
return File;
|
|
134
|
-
} finally {
|
|
135
|
-
if (tempIFrame) {
|
|
136
|
-
tempIFrame.parentElement.remove(frame);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
} else {
|
|
140
|
-
return window.File;
|
|
141
|
-
}
|
|
142
|
-
})();
|
|
143
|
-
const element = getLocatedElement(locatedElement);
|
|
144
|
-
if(!element) {
|
|
145
|
-
throw new Error('element not found');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function getFileBlob(url) {
|
|
149
|
-
return new Promise((resolve, reject) => {
|
|
150
|
-
var xhr = new XMLHttpRequest();
|
|
151
|
-
xhr.open('GET', url, true);
|
|
152
|
-
xhr.responseType = 'blob';
|
|
153
|
-
|
|
154
|
-
xhr.onload = function() {
|
|
155
|
-
if (this.status === 200) {
|
|
156
|
-
resolve(this.response);
|
|
157
|
-
} else {
|
|
158
|
-
reject(new Error('Could not load file, failure status:' + this.status));
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
xhr.onerror = function(e) {
|
|
162
|
-
reject(new Error("Error " + e.target.status + " occurred while loading the file."));
|
|
163
|
-
};
|
|
164
|
-
xhr.send();
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const fileList = await Promise.all(fileUrls.map(async ({ url, name }) => {
|
|
170
|
-
let blob;
|
|
171
|
-
try {
|
|
172
|
-
const res = await fetch(url)
|
|
173
|
-
blob = await res.blob();
|
|
174
|
-
} catch (err) {
|
|
175
|
-
blob = await getFileBlob(url); // Sometimes the fetch fails, try using XHR as fallback
|
|
176
|
-
}
|
|
177
|
-
return new File([blob], name, { type: blob.type });
|
|
178
|
-
}));
|
|
179
|
-
|
|
180
|
-
const dt = new DataTransfer();
|
|
181
|
-
for (const file of fileList) {
|
|
182
|
-
dt.items.add(file);
|
|
183
|
-
}
|
|
184
|
-
element.files = dt.files;
|
|
185
|
-
|
|
186
|
-
let changeWasFired = false;
|
|
187
|
-
const changeFiredHandler = (e) => {
|
|
188
|
-
changeWasFired = true;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
element.addEventListener("change", changeFiredHandler, true);
|
|
192
|
-
await Promise.resolve(); // wait microtick
|
|
193
|
-
element.dispatchEvent(new Event("input", { bubbles: true }));
|
|
194
|
-
if (!changeWasFired) {
|
|
195
|
-
element.dispatchEvent(new Event("change", { bubbles: true }));
|
|
196
|
-
}
|
|
197
|
-
element.removeEventListener("change", changeFiredHandler, true);
|
|
198
|
-
}`;
|
|
199
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const StepAction = require('./stepAction');
|
|
6
|
-
const featureFlags = require('../../commons/featureFlags');
|
|
7
|
-
const { JSDOM, VirtualConsole } = require('jsdom');
|
|
8
|
-
const { getLogger } = require('../../commons/logger');
|
|
9
|
-
const { getSessionPlayer } = require('../../commons/getSessionPlayerRequire');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const logger = getLogger('locate-step-action');
|
|
13
|
-
const DEFAULT_VISIBILITY_RESULT = { opacity: 1, clientRects: {} };
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @param {import('../webdriver')} driver
|
|
17
|
-
*/
|
|
18
|
-
function createUtils(driver) {
|
|
19
|
-
return {
|
|
20
|
-
getFrameIdByTestimFrameId() { },
|
|
21
|
-
|
|
22
|
-
async setElementResultDataOnContext(target) {
|
|
23
|
-
const seleniumResponse = await driver.getElement(target.locatedElement);
|
|
24
|
-
target.seleniumElement = seleniumResponse.value;
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
getElementRectangle(target) {
|
|
28
|
-
return driver.getElementRect(target);
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
getOffsets(frameHandler) {
|
|
32
|
-
return Promise.resolve([frameHandler.frameOffset || {}]);
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
/** @type {typeof import('clickim/src/background/stepActions/locateStepAction').LocateStepAction['htmlStringToDom']} */
|
|
36
|
-
htmlStringToDom(htmlString, url, nonBodyElements, bodyTagName, setDomTimeout = true) {
|
|
37
|
-
const virtualConsole = new VirtualConsole();
|
|
38
|
-
const jsdom = new JSDOM(htmlString, {
|
|
39
|
-
virtualConsole,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const { window } = jsdom;
|
|
43
|
-
if (setDomTimeout) {
|
|
44
|
-
// memory leak fix.
|
|
45
|
-
// this used to be nexttick, but it was too soon.
|
|
46
|
-
|
|
47
|
-
setTimeout(() => {
|
|
48
|
-
window.close();
|
|
49
|
-
}, 1000 * 60);
|
|
50
|
-
}
|
|
51
|
-
return Object.assign(window.document, { TESTIM_URL: url });
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
shouldUseNativeVisibilityCheck(locateStep, driver, visibilityUtils, positionUtils) {
|
|
55
|
-
if (locateStep.opacity === 0) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
if (locateStep.isShadowed) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
if ((visibilityUtils === undefined) || (positionUtils === undefined)) {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
if (featureFlags.flags.useClickimVisibilityChecks.isEnabled()) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
if (driver.isSafari()) {
|
|
68
|
-
return featureFlags.flags.useSafariWebdriverVisibilityChecks.isEnabled();
|
|
69
|
-
}
|
|
70
|
-
return true;
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
/** @type {typeof import('clickim/src/background/stepActions/locateStepAction').LocateStepAction['isVisible']} */
|
|
74
|
-
async isVisible(target, targetElement, rect, locateStep, frameHandler, allOffsets, dom) {
|
|
75
|
-
const { locatorBuilderUtils, codeSnippets, visibilityUtils, positionUtils } = getSessionPlayer();
|
|
76
|
-
const useNativeVisibilityCheck = this.shouldUseNativeVisibilityCheck(locateStep, driver, visibilityUtils, positionUtils);
|
|
77
|
-
if (useNativeVisibilityCheck) {
|
|
78
|
-
return driver.isVisible(target.seleniumElement);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (!target.seleniumElement) {
|
|
82
|
-
return { visible: false, invisibleReason: 'element not found' };
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// this is here for the side effects.
|
|
86
|
-
try {
|
|
87
|
-
await driver.isVisible(target.seleniumElement);
|
|
88
|
-
} catch {
|
|
89
|
-
/* ignored */
|
|
90
|
-
}
|
|
91
|
-
if (!targetElement || locatorBuilderUtils.isEmptyResult(targetElement)) {
|
|
92
|
-
return { visible: false, invisibleReason: 'element not found' };
|
|
93
|
-
}
|
|
94
|
-
const middlePosition = positionUtils.calculateElementMiddlePoint(rect);
|
|
95
|
-
const points = [middlePosition, positionUtils.calculateClickPoint(locateStep.clickOffset, rect)].filter(Boolean);
|
|
96
|
-
const code = codeSnippets.getVisibilityCode.getCompoundVisibilityInfoCode(target.locatedElement, points, false, locateStep);
|
|
97
|
-
let response;
|
|
98
|
-
try {
|
|
99
|
-
response = await driver.execute(`return ${code}`);
|
|
100
|
-
} catch (err) {
|
|
101
|
-
logger.error('failed to execute getVisibilityCode', { err });
|
|
102
|
-
throw err;
|
|
103
|
-
}
|
|
104
|
-
const { value } = response || {};
|
|
105
|
-
const elementVisibilityInfo = value.elementVisibilityInfo || DEFAULT_VISIBILITY_RESULT;
|
|
106
|
-
const [middleElementFromPoint, clickElementFromPoint] = value.elementsFromPointResults || [null, null];
|
|
107
|
-
return visibilityUtils.checkElementVisibility(elementVisibilityInfo, locateStep, clickElementFromPoint, middleElementFromPoint, dom, targetElement);
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
scrollToElement(frameHandler, locatedElement) {
|
|
111
|
-
const { codeSnippets } = getSessionPlayer();
|
|
112
|
-
const code = codeSnippets.scrollToElement;
|
|
113
|
-
return driver.execute(code(locatedElement));
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
class LocateStepAction extends StepAction {
|
|
119
|
-
execute() {
|
|
120
|
-
return this.driver.getHTML(this.step);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
static getUtils(driver) {
|
|
124
|
-
return Object.assign(createUtils(driver), { useLocatedElement: true });
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
static getFrameIdByTestimFrameId(...args) {
|
|
128
|
-
logger.warn('Unplanned access to getFrameIdByTestimFrameId()');
|
|
129
|
-
throw new Error('Use .getUtils() instead');
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
static setElementResultDataOnContext(...args) {
|
|
133
|
-
logger.warn('Unplanned access to setElementResultDataOnContext()');
|
|
134
|
-
throw new Error('Use .getUtils() instead');
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
static getElementRectangle(...args) {
|
|
138
|
-
logger.warn('Unplanned access to getElementRectangle()');
|
|
139
|
-
throw new Error('Use .getUtils() instead');
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
static getOffsets(...args) {
|
|
143
|
-
logger.warn('Unplanned access to getOffsets()');
|
|
144
|
-
throw new Error('Use .getUtils() instead');
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
static htmlStringToDom(...args) {
|
|
148
|
-
logger.warn('Unplanned access to htmlStringToDom()');
|
|
149
|
-
throw new Error('Use .getUtils() instead');
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
static isVisible(...args) {
|
|
153
|
-
logger.warn('Unplanned access to isVisible()');
|
|
154
|
-
throw new Error('Use .getUtils() instead');
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
module.exports = LocateStepAction;
|
|
159
|
-
|