@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,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const StepAction = require('./stepAction');
|
|
4
|
-
|
|
5
|
-
class RefreshStepAction extends StepAction {
|
|
6
|
-
async execute() {
|
|
7
|
-
try {
|
|
8
|
-
await this.driver.reloadTab();
|
|
9
|
-
return { success: true };
|
|
10
|
-
} catch (error) {
|
|
11
|
-
return { success: false, reason: error.message };
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
module.exports = RefreshStepAction;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const StepAction = require('./stepAction');
|
|
6
|
-
|
|
7
|
-
class ApiStepAction extends StepAction {
|
|
8
|
-
async runApiInAut(eventData) {
|
|
9
|
-
eventData.withCredentials = true;
|
|
10
|
-
const timeout = this.context.data.timeToPlayStep + 3000;
|
|
11
|
-
const { apiCall } = this.sessionPlayerInit;
|
|
12
|
-
try {
|
|
13
|
-
const autRes = await this.driver.executeCodeAsync(apiCall, timeout, eventData);
|
|
14
|
-
const resp = autRes?.value;
|
|
15
|
-
return resp || {};
|
|
16
|
-
} catch (err) {
|
|
17
|
-
if (err?.message?.includes('Javascript execution context no longer exists')) {
|
|
18
|
-
throw new Error(
|
|
19
|
-
'The page refreshed or changed while executing this step. Please consider unchecking "Send via web page" if this is expected.');
|
|
20
|
-
}
|
|
21
|
-
throw err;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
runApiInBg(eventData) {
|
|
26
|
-
const { apiCall } = this.sessionPlayerInit;
|
|
27
|
-
return new Promise(resolve => { apiCall(eventData, resolve); });
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async performAction() {
|
|
31
|
-
const { commonConstants } = this.sessionPlayerInit;
|
|
32
|
-
/** @type {import('clickim/src/common/models/apiStep').ApiStep} */
|
|
33
|
-
const step = this.step;
|
|
34
|
-
const context = this.context;
|
|
35
|
-
|
|
36
|
-
const eventData = {
|
|
37
|
-
id: step.id,
|
|
38
|
-
url: context.apiUrl,
|
|
39
|
-
method: step.method,
|
|
40
|
-
headers: context.apiHeaders,
|
|
41
|
-
body: context.apiBody,
|
|
42
|
-
timeout: context.data.maxTotalStepTime,
|
|
43
|
-
omitCookies: step.omitCookies,
|
|
44
|
-
formData: step.formData,
|
|
45
|
-
fileUrls: context.fileUrls,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
let resp;
|
|
49
|
-
if (step.sendViaWebApp) {
|
|
50
|
-
resp = await this.runApiInAut(eventData);
|
|
51
|
-
} else {
|
|
52
|
-
resp = await this.runApiInBg(eventData);
|
|
53
|
-
}
|
|
54
|
-
const result = resp.result || {};
|
|
55
|
-
const resultInfo = {
|
|
56
|
-
method: step.method,
|
|
57
|
-
status: result.status,
|
|
58
|
-
url: step.url,
|
|
59
|
-
};
|
|
60
|
-
if (resp.success) {
|
|
61
|
-
if (result.status === 0) {
|
|
62
|
-
return {
|
|
63
|
-
result,
|
|
64
|
-
resultInfo,
|
|
65
|
-
shouldRetry: false,
|
|
66
|
-
success: false,
|
|
67
|
-
reason: 'Connection problem',
|
|
68
|
-
errorType: commonConstants.stepResult.API_REQUEST_NETWORK_ERROR,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
result,
|
|
73
|
-
resultInfo,
|
|
74
|
-
shouldRetry: false,
|
|
75
|
-
success: true,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
result,
|
|
80
|
-
resultInfo,
|
|
81
|
-
shouldRetry: false,
|
|
82
|
-
success: false,
|
|
83
|
-
reason: result.error || commonConstants.error.REQUEST_TIMED_OUT,
|
|
84
|
-
errorType: result.error ? commonConstants.stepResult.API_FAILURE : commonConstants.stepResult.API_REQUEST_NETWORK_ERROR,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
module.exports = ApiStepAction;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const utils = require('../../utils');
|
|
4
|
-
const BaseJsStepAction = require('./baseJsStepAction');
|
|
5
|
-
const service = require('../../agent/routers/cliJsCode/service');
|
|
6
|
-
|
|
7
|
-
class BaseCliJsStepAction extends BaseJsStepAction {
|
|
8
|
-
async executeCliCode() {
|
|
9
|
-
const { step, context } = this;
|
|
10
|
-
const isMobile = this.stepActionUtils.driver.isMobile;
|
|
11
|
-
const hasCliAction = context.company?.activePlan?.premiumFeatures?.cliAction;
|
|
12
|
-
|
|
13
|
-
if (!hasCliAction && !isMobile) {
|
|
14
|
-
return {
|
|
15
|
-
success: 'skipped',
|
|
16
|
-
reason: 'CLI action is not enabled in your current plan',
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const { code, id } = step;
|
|
21
|
-
const { incomingParams, testResultId, retryIndex, stepResultId } = context;
|
|
22
|
-
const contextData = {
|
|
23
|
-
config: context.config,
|
|
24
|
-
data: context.data,
|
|
25
|
-
};
|
|
26
|
-
const runTimeout = context.data.timeToPlayStep;
|
|
27
|
-
const data = await service.runCodeWithPackages(code, id, incomingParams, contextData, testResultId, retryIndex, stepResultId, runTimeout);
|
|
28
|
-
return await this.checkCodeResponse(data);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async performAction() {
|
|
32
|
-
try {
|
|
33
|
-
return await this.executeCliCode();
|
|
34
|
-
} catch (err) {
|
|
35
|
-
const { stepResult } = this.sessionPlayerInit.commonConstants;
|
|
36
|
-
if (err instanceof utils.TimeoutError) {
|
|
37
|
-
return {
|
|
38
|
-
success: false,
|
|
39
|
-
errorType: stepResult.ACTION_TIMEOUT,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
success: false,
|
|
44
|
-
reason: err.message,
|
|
45
|
-
exception: err,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
module.exports = BaseCliJsStepAction;
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const _ = require('lodash');
|
|
5
|
-
const utils = require('../../utils');
|
|
6
|
-
const StepAction = require('./stepAction');
|
|
7
|
-
const runnerUtils = require('../../utils');
|
|
8
|
-
const runCodeScript = require('./scripts/runCode');
|
|
9
|
-
const featureFlags = require('../../commons/featureFlags');
|
|
10
|
-
const { getLogger } = require('../../commons/logger');
|
|
11
|
-
|
|
12
|
-
const logger = getLogger('base-js-step-action');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class BaseJsStepAction extends StepAction {
|
|
16
|
-
isExceedingMaxResultSize(data, context) {
|
|
17
|
-
try {
|
|
18
|
-
const shouldEnforceMaxSize = context.project.defaults.enforceMaximumJsResultSize;
|
|
19
|
-
const maximumJsResultSize = featureFlags.flags.maximumJsResultSize.getValue();
|
|
20
|
-
const dataSizeExceeded = JSON.stringify(data).length > maximumJsResultSize;
|
|
21
|
-
if (!shouldEnforceMaxSize) {
|
|
22
|
-
if (dataSizeExceeded) {
|
|
23
|
-
logger.warn(`js result size exceeded ${maximumJsResultSize}, stepId: ${this.step.id}`);
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
return dataSizeExceeded;
|
|
28
|
-
} catch (e) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
executeGetStatus(transactionId) {
|
|
34
|
-
return this.driver.executeJS(_transactionId => {
|
|
35
|
-
/* eslint-disable no-undef */
|
|
36
|
-
const sessionItem = `data-testim-${_transactionId}`;
|
|
37
|
-
try {
|
|
38
|
-
return window.sessionStorage.getItem(sessionItem);
|
|
39
|
-
} catch (err) {
|
|
40
|
-
if (
|
|
41
|
-
err.message.includes('sessionStorage') || // Chrome + Firefox
|
|
42
|
-
err.message.includes('The operation is insecure') // Safari
|
|
43
|
-
) {
|
|
44
|
-
const storage = document.head.querySelector('#testim-storage-backup');
|
|
45
|
-
if (!storage) {
|
|
46
|
-
return '{}';
|
|
47
|
-
}
|
|
48
|
-
return storage.getAttribute(sessionItem);
|
|
49
|
-
}
|
|
50
|
-
throw err;
|
|
51
|
-
}
|
|
52
|
-
/* eslint-enable no-undef */
|
|
53
|
-
}, transactionId);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
constructJSFunParams(eventData) {
|
|
57
|
-
const incomingParams = eventData.incomingParams;
|
|
58
|
-
|
|
59
|
-
const params = [
|
|
60
|
-
'context', ...incomingParams.as.functionParameters,
|
|
61
|
-
'exports', 'exportsTest', 'exportsGlobal',
|
|
62
|
-
];
|
|
63
|
-
|
|
64
|
-
const args = [eventData.context, ...incomingParams.as.functionArguments];
|
|
65
|
-
|
|
66
|
-
params.push(eventData.code);
|
|
67
|
-
args.forEach(arg => {
|
|
68
|
-
if (_.isObject(arg)) {
|
|
69
|
-
runnerUtils.removePropertyFromObject(arg, 'seleniumElement', _.isEqual);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
return {
|
|
73
|
-
function: {
|
|
74
|
-
params,
|
|
75
|
-
args,
|
|
76
|
-
},
|
|
77
|
-
transactionId: eventData.transactionId,
|
|
78
|
-
browser: eventData.browser,
|
|
79
|
-
browserMajor: eventData.browserMajor,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
checkStatus(transactionId) {
|
|
85
|
-
const that = this;
|
|
86
|
-
const retryInterval = that.context.config.retryTimeout;
|
|
87
|
-
let timeToPlayStep = that.context.data.timeToPlayStep - retryInterval;
|
|
88
|
-
async function checkScriptStatus() {
|
|
89
|
-
let selRes;
|
|
90
|
-
try {
|
|
91
|
-
selRes = await that.executeGetStatus(transactionId);
|
|
92
|
-
} catch (err) {
|
|
93
|
-
logger.warn('failed to get js status', { err });
|
|
94
|
-
selRes = { value: { status: 'exception' } };
|
|
95
|
-
}
|
|
96
|
-
let res;
|
|
97
|
-
try {
|
|
98
|
-
res = JSON.parse(selRes ? selRes.value : '{}');
|
|
99
|
-
} catch (e) {
|
|
100
|
-
logger.warn('non object value', { selRes });
|
|
101
|
-
res = { status: 'exception' };
|
|
102
|
-
}
|
|
103
|
-
const abortReason = that.stepActionUtils.abortedSteps.find(abortedStep => abortedStep.id === that.step.id);
|
|
104
|
-
if (abortReason) {
|
|
105
|
-
return abortReason;
|
|
106
|
-
}
|
|
107
|
-
if (!res) {
|
|
108
|
-
return { success: true };
|
|
109
|
-
}
|
|
110
|
-
if (res.status && res.status === 'done') {
|
|
111
|
-
return res;
|
|
112
|
-
}
|
|
113
|
-
if (res.status && res.status === 'failed') {
|
|
114
|
-
return { success: false, shouldRetry: true, result: res.result };
|
|
115
|
-
}
|
|
116
|
-
if (timeToPlayStep - retryInterval <= 0) {
|
|
117
|
-
return Object.assign(res, { success: false, shouldRetry: true });
|
|
118
|
-
}
|
|
119
|
-
timeToPlayStep -= retryInterval;
|
|
120
|
-
await utils.delay(retryInterval);
|
|
121
|
-
return checkScriptStatus();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return checkScriptStatus();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
executeInAut(eventMessage) {
|
|
128
|
-
const useExperimentalPreCompilation = featureFlags.flags.experimentalPreCodeCompilation.isEnabled();
|
|
129
|
-
const experimentalAsyncCustomCode = featureFlags.flags.experimentalAsyncCustomCode.isEnabled();
|
|
130
|
-
const rawParams = this.constructJSFunParams(eventMessage);
|
|
131
|
-
const hasLocateParams = rawParams.function.args.some(x => Boolean(x?.locatedElement));
|
|
132
|
-
let funcToRunString = 'undefined';
|
|
133
|
-
if (useExperimentalPreCompilation) {
|
|
134
|
-
const paramNames = rawParams.function.params.slice(0, -1);
|
|
135
|
-
funcToRunString = experimentalAsyncCustomCode ? `async function(${paramNames.join(',')}) {
|
|
136
|
-
${eventMessage.code}
|
|
137
|
-
};` : `function(${paramNames.join(',')}) {
|
|
138
|
-
${eventMessage.code}
|
|
139
|
-
};`;
|
|
140
|
-
// remove code from call.
|
|
141
|
-
rawParams.function.params.pop();
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const { codeSnippets } = this.sessionPlayerInit;
|
|
145
|
-
|
|
146
|
-
const runCode = `
|
|
147
|
-
${hasLocateParams ? `var getLocatedElement = ${codeSnippets.getLocatedElementCode};` : ';'}
|
|
148
|
-
var runCode = ${runCodeScript.toString()};
|
|
149
|
-
var eventData = arguments[0];
|
|
150
|
-
var funcToRun = ${funcToRunString};
|
|
151
|
-
return runCode.call(null, eventData, funcToRun);
|
|
152
|
-
`;
|
|
153
|
-
if (!useExperimentalPreCompilation) {
|
|
154
|
-
return this.driver.executeJS(runCode, rawParams);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return this.driver.executeJS(runCode, rawParams).catch(err => this.handleExecutionError(err));
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
codeExecDone(resp) {
|
|
161
|
-
const { stepResult: constants } = this.sessionPlayerInit.commonConstants;
|
|
162
|
-
const { context } = this;
|
|
163
|
-
const {
|
|
164
|
-
result = {}, tstConsoleLogs, nodeVersion, navigateToDifferentDomain,
|
|
165
|
-
} = resp;
|
|
166
|
-
if (result.exports) {
|
|
167
|
-
context.data.exports = result.exports;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const resultObj = {
|
|
171
|
-
nodeVersion,
|
|
172
|
-
tstConsoleLogs,
|
|
173
|
-
data: context.data,
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
if (this.isFailedResult(result.resultValue)) {
|
|
177
|
-
Object.assign(resultObj, {
|
|
178
|
-
success: false,
|
|
179
|
-
errorType: constants.JS_ASSERTION_FAILED,
|
|
180
|
-
});
|
|
181
|
-
} else if (this.isExceedingMaxResultSize({ result, tstConsoleLogs }, context)) {
|
|
182
|
-
Object.assign(resultObj, {
|
|
183
|
-
success: false,
|
|
184
|
-
errorType: constants.JS_RESULT_MAX_SIZE_EXCEEDED,
|
|
185
|
-
});
|
|
186
|
-
} else {
|
|
187
|
-
Object.assign(resultObj, {
|
|
188
|
-
success: true,
|
|
189
|
-
exportsTest: result.exportsTest,
|
|
190
|
-
exportsGlobal: result.exportsGlobal,
|
|
191
|
-
});
|
|
192
|
-
if (navigateToDifferentDomain) {
|
|
193
|
-
resultObj.navigateToDifferentDomain = navigateToDifferentDomain;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return Promise.resolve(resultObj);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
codeExecFailed(resp) {
|
|
200
|
-
const { stepResult: constants } = this.sessionPlayerInit.commonConstants;
|
|
201
|
-
const { context } = this;
|
|
202
|
-
if (resp.type === 'promise') {
|
|
203
|
-
return Promise.resolve({
|
|
204
|
-
data: context.data,
|
|
205
|
-
success: false,
|
|
206
|
-
shouldRetry: true,
|
|
207
|
-
isPendingPromise: true,
|
|
208
|
-
errorType: constants.JS_ASSERTION_FAILED,
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
if (resp.reason === 'stopped') {
|
|
212
|
-
return Promise.resolve(Object.assign({}, resp, { errorType: constants.STOPPED }));
|
|
213
|
-
}
|
|
214
|
-
const { result = {}, tstConsoleLogs } = resp;
|
|
215
|
-
const message = {
|
|
216
|
-
tstConsoleLogs,
|
|
217
|
-
data: context.data,
|
|
218
|
-
exportsGlobal: result.exportsGlobal,
|
|
219
|
-
exportsTest: result.exportsTest,
|
|
220
|
-
success: false,
|
|
221
|
-
errorType: constants.UNWRAPPED_AUT_REJECT,
|
|
222
|
-
resultInfo: { error: result.resultValue },
|
|
223
|
-
};
|
|
224
|
-
return Promise.resolve(message);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
checkCodeResponse(resp) {
|
|
228
|
-
return resp?.success ? this.codeExecDone(resp) : this.codeExecFailed(resp);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
async performAction() {
|
|
232
|
-
const step = this.step;
|
|
233
|
-
const context = this.context;
|
|
234
|
-
|
|
235
|
-
this.startTimestamp = Date.now();
|
|
236
|
-
|
|
237
|
-
const eventMessage = {
|
|
238
|
-
transactionId: `${context.testResultId}:${step.id}`,
|
|
239
|
-
id: step.id,
|
|
240
|
-
eventType: step.type,
|
|
241
|
-
code: step.code,
|
|
242
|
-
incomingParams: context.incomingParams,
|
|
243
|
-
exportsGlobal: this.exportsGlobal,
|
|
244
|
-
exportsTest: this.exportsTest,
|
|
245
|
-
context: {
|
|
246
|
-
config: context.config,
|
|
247
|
-
data: context.data,
|
|
248
|
-
},
|
|
249
|
-
testResultId: context.testResultId,
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
const browserAndOS = await this.driver.getBrowserAndOS();
|
|
253
|
-
Object.assign(eventMessage, { browser: browserAndOS.browser, browserMajor: browserAndOS.browserMajor });
|
|
254
|
-
|
|
255
|
-
if (!this.context.isPendingPromise) {
|
|
256
|
-
await this.executeInAut(eventMessage);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
const resp = await this.checkStatus(eventMessage.transactionId);
|
|
260
|
-
return await this.checkCodeResponse(resp);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
handleExecutionError(err) {
|
|
264
|
-
const canExtractError = err?.seleniumStack && err.seleniumStack.type === 'JavaScriptError' &&
|
|
265
|
-
err.seleniumStack.orgStatusMessage;
|
|
266
|
-
|
|
267
|
-
if (canExtractError) {
|
|
268
|
-
const endOfMessage = err.seleniumStack.orgStatusMessage.indexOf('\nBuild info');
|
|
269
|
-
const reason = err.seleniumStack.orgStatusMessage.slice(0, endOfMessage === -1 ? undefined : endOfMessage);
|
|
270
|
-
throw new Error(reason);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
throw err;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
module.exports = BaseJsStepAction;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const StepAction = require('./stepAction');
|
|
4
|
-
const featureFlagService = require('../../commons/featureFlags');
|
|
5
|
-
const downloadFileAndFireDropEvent = require('./scripts/dropEvent');
|
|
6
|
-
const { getLogger } = require('../../commons/logger');
|
|
7
|
-
|
|
8
|
-
const logger = getLogger('drop-file-step-action');
|
|
9
|
-
|
|
10
|
-
class DropFileStepAction extends StepAction {
|
|
11
|
-
async performAction() {
|
|
12
|
-
const { codeSnippets, utils } = this.sessionPlayerInit;
|
|
13
|
-
const target = this.context.data[this.step.targetId || 'targetId'];
|
|
14
|
-
const overrideAzureStorageUrl = featureFlagService.flags.overrideAzureStorageUrl.isEnabled();
|
|
15
|
-
const fileUrls = await utils.addTokenToFileUrl(
|
|
16
|
-
this.context.project.id,
|
|
17
|
-
this.step.fileUrls,
|
|
18
|
-
this.stepActionUtils.testimServicesApi,
|
|
19
|
-
overrideAzureStorageUrl,
|
|
20
|
-
logger,
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const dropFileCode = `
|
|
24
|
-
var getLocatedElement = ${codeSnippets.getLocatedElementCode};
|
|
25
|
-
var createDropEvent = ${codeSnippets.createDropEvent.toString()};
|
|
26
|
-
var downloadFileAndFireDropEvent = ${downloadFileAndFireDropEvent.toString()};
|
|
27
|
-
return downloadFileAndFireDropEvent.apply(null, arguments)
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
return await this.driver.executeJSWithArray(dropFileCode, [target.locatedElement, fileUrls]);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
module.exports = DropFileStepAction;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const _ = require('lodash');
|
|
4
|
-
const StepAction = require('./stepAction');
|
|
5
|
-
const { getLogger } = require('../../commons/logger');
|
|
6
|
-
|
|
7
|
-
const logger = getLogger('evaluate-expression-step-action');
|
|
8
|
-
|
|
9
|
-
class EvaluateExpressionStepAction extends StepAction {
|
|
10
|
-
async execute() {
|
|
11
|
-
const step = this.step;
|
|
12
|
-
const context = this.context;
|
|
13
|
-
const exportsGlobal = this.exportsGlobal;
|
|
14
|
-
const exportsTest = this.exportsTest;
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
logger.info('runner running incoming params evaluation');
|
|
18
|
-
let incomingParams = context.incomingParams || {};
|
|
19
|
-
if (_.isEmpty(incomingParams)) {
|
|
20
|
-
incomingParams = this.sessionPlayerInit.stepParamBuilder.getStepInputs(step, context, exportsGlobal, exportsTest);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const params = ['context', ...incomingParams.as.functionParameters];
|
|
24
|
-
const args = [context, ...incomingParams.as.functionArguments];
|
|
25
|
-
const expressionToEvaluate = step.subType === 'text' ? `'${step.expression.replace(/'/g, "\\\'")}'` : step.expression;
|
|
26
|
-
const code = `return ${expressionToEvaluate}`.replace(/\n/g, '\\n');
|
|
27
|
-
const textEvaluateFunction = Function.apply(Function, params.concat([code]));
|
|
28
|
-
const evaluatedText = textEvaluateFunction.apply(null, args);
|
|
29
|
-
|
|
30
|
-
context.data[step.targetName] = evaluatedText;
|
|
31
|
-
context.data[step.targetId] = evaluatedText;
|
|
32
|
-
if (context.internalParams) {
|
|
33
|
-
context.internalParams.add(step.targetId);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const result = {
|
|
37
|
-
success: true,
|
|
38
|
-
evaluatedText,
|
|
39
|
-
data: context.data,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
return result;
|
|
43
|
-
} catch (e) {
|
|
44
|
-
const { stepResult } = this.sessionPlayerInit.commonConstants;
|
|
45
|
-
// TODO: Fix throwing non-error
|
|
46
|
-
// eslint-disable-next-line no-throw-literal
|
|
47
|
-
throw { errorType: stepResult.EVALUATE_EXPRESSION_EXCEPTION, resultInfo: { exception: e.toString() }, success: false };
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
module.exports = EvaluateExpressionStepAction;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const StepAction = require('./stepAction');
|
|
2
|
-
|
|
3
|
-
class ExtensionOnlyStepAction extends StepAction {
|
|
4
|
-
async performAction() {
|
|
5
|
-
return {
|
|
6
|
-
success: 'skipped',
|
|
7
|
-
reason: 'This step can run only on Chrome',
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
module.exports = ExtensionOnlyStepAction;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const StepAction = require('./stepAction');
|
|
4
|
-
|
|
5
|
-
class ExtractTextStepAction extends StepAction {
|
|
6
|
-
async performAction() {
|
|
7
|
-
const paramName = this.step.extractTextParamName;
|
|
8
|
-
|
|
9
|
-
const extractedText = await this.stepActionUtils.extractTargetText(this.getTarget());
|
|
10
|
-
this.context.data.exports = this.context.data.exports || {};
|
|
11
|
-
this.context.data.exports[paramName] = extractedText;
|
|
12
|
-
return {
|
|
13
|
-
success: true,
|
|
14
|
-
data: this.context.data,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
module.exports = ExtractTextStepAction;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const StepAction = require('./stepAction');
|
|
2
|
-
|
|
3
|
-
const toDOMRect = (height, width, x, y) => ({
|
|
4
|
-
x,
|
|
5
|
-
y,
|
|
6
|
-
width,
|
|
7
|
-
height,
|
|
8
|
-
get top() { return this.y; },
|
|
9
|
-
get left() { return this.x; },
|
|
10
|
-
get right() { return this.x + this.width; },
|
|
11
|
-
get bottom() { return this.y + this.height; },
|
|
12
|
-
toJSON() { },
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
class HoverStepAction extends StepAction {
|
|
16
|
-
getRect() {
|
|
17
|
-
return this.driver.isFirefox() ?
|
|
18
|
-
this.getTarget().rectWithoutFrameOffset :
|
|
19
|
-
this.getTarget().rect;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async performAction() {
|
|
23
|
-
const target = this.getTarget();
|
|
24
|
-
const { seleniumElement, rectWithoutFrameOffset, rect } = target;
|
|
25
|
-
|
|
26
|
-
const { width, height } = rect;
|
|
27
|
-
|
|
28
|
-
let clickOffsetX = width / 2;
|
|
29
|
-
let clickOffsetY = height / 2;
|
|
30
|
-
|
|
31
|
-
const offset = this.step.element.clickOffset;
|
|
32
|
-
if (offset && this.step.shouldAccountForMouseOffsetInHover) {
|
|
33
|
-
const { x, y } = offset;
|
|
34
|
-
|
|
35
|
-
if (this.sessionPlayerInit.utils.isWithinTargetRect(toDOMRect(height, width, 0, 0), x, y)) {
|
|
36
|
-
clickOffsetX = x;
|
|
37
|
-
clickOffsetY = y;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const offsets = {
|
|
42
|
-
frameOffset: {
|
|
43
|
-
x: rect.left - rectWithoutFrameOffset.left,
|
|
44
|
-
y: rect.top - rectWithoutFrameOffset.top,
|
|
45
|
-
},
|
|
46
|
-
rect: rectWithoutFrameOffset,
|
|
47
|
-
clickOffset: { x: Math.floor(clickOffsetX), y: Math.floor(clickOffsetY) },
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
await this.driver.hover(seleniumElement, offsets);
|
|
51
|
-
return { success: true };
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
module.exports = HoverStepAction;
|