@testim/testim-cli 3.289.0 → 3.290.0-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 +8 -29129
- 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
package/inputFileUtils.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const httpRequest = require('./commons/httpRequest');
|
|
4
|
-
const fsPromises = require('fs/promises');
|
|
5
|
-
const os = require('os');
|
|
6
|
-
const { promiseMap } = require('./utils');
|
|
7
|
-
const { getLogger } = require('./commons/logger');
|
|
8
|
-
|
|
9
|
-
const logger = getLogger('input-file-utils');
|
|
10
|
-
|
|
11
|
-
function getVisibleElementScript(positionAndSize = {
|
|
12
|
-
width: '2px', height: '2px', left: '0px', top: '400px',
|
|
13
|
-
}) {
|
|
14
|
-
const zIndex = 100000000;
|
|
15
|
-
const opacity = 1;
|
|
16
|
-
return `function getVisibleElement(locatedElement) {
|
|
17
|
-
var input = getLocatedElement(locatedElement);
|
|
18
|
-
if(input) {
|
|
19
|
-
function parents(element, _elements) {
|
|
20
|
-
_elements = _elements || [];
|
|
21
|
-
_elements.push(element);
|
|
22
|
-
if(element.parentNode && element.tagName !== 'BODY') {
|
|
23
|
-
return parents(element.parentNode, _elements);
|
|
24
|
-
}
|
|
25
|
-
return _elements;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function forceStyle(el, name, value) {
|
|
29
|
-
el.style.setProperty(name, value, 'important');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
Array.apply(null, parents(input)).forEach(function(el) {
|
|
33
|
-
let element = el;
|
|
34
|
-
if (element instanceof DocumentFragment) {
|
|
35
|
-
element = element.host
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var displayMode = window.getComputedStyle(element).display;
|
|
39
|
-
if(displayMode === "none") {
|
|
40
|
-
forceStyle(element, 'display', 'block');
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
forceStyle(input, 'visibility', 'visible');
|
|
45
|
-
forceStyle(input, 'width', '${positionAndSize.width}');
|
|
46
|
-
forceStyle(input, 'max-width', '${positionAndSize.width}');
|
|
47
|
-
forceStyle(input, 'height', '${positionAndSize.height}');
|
|
48
|
-
forceStyle(input, 'max-height', '${positionAndSize.height}');
|
|
49
|
-
forceStyle(input, 'z-index', ${zIndex});
|
|
50
|
-
forceStyle(input, 'opacity', ${opacity});
|
|
51
|
-
forceStyle(input, 'top', '${positionAndSize.top}');
|
|
52
|
-
forceStyle(input, 'left', '${positionAndSize.left}');
|
|
53
|
-
forceStyle(input, 'position', 'fixed');
|
|
54
|
-
forceStyle(input, 'pointer-events', 'all');
|
|
55
|
-
input.removeAttribute("disabled");
|
|
56
|
-
input.focus();
|
|
57
|
-
}
|
|
58
|
-
}`;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async function downloadFile(fileUrl, fileName) {
|
|
62
|
-
let body = null;
|
|
63
|
-
try {
|
|
64
|
-
const res = await httpRequest.download(fileUrl);
|
|
65
|
-
body = res.body;
|
|
66
|
-
} catch (err) {
|
|
67
|
-
logger.error('failed to download input-file content',
|
|
68
|
-
{ err: { message: err.message, stack: err.stack, status: err.status } });
|
|
69
|
-
if (err.response) {
|
|
70
|
-
// try to emulate what we essentially do in clickim
|
|
71
|
-
body = err.response.body;
|
|
72
|
-
} else {
|
|
73
|
-
// we have a circular object
|
|
74
|
-
if (err.cause) {
|
|
75
|
-
throw new Error(err.message);
|
|
76
|
-
}
|
|
77
|
-
throw err;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const localFileLocation = `${os.tmpdir()}/${fileName}`;
|
|
82
|
-
await fsPromises.writeFile(localFileLocation, body);
|
|
83
|
-
return localFileLocation;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function downloadFiles(fileUrls) {
|
|
87
|
-
return promiseMap(fileUrls, file => downloadFile(file.url, file.name));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function uploadFileToGrid(localFileLocation, uploadFileFn) {
|
|
91
|
-
return uploadFileFn(localFileLocation);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async function downloadFilesAndUploadToGrid(fileUrls, uploadFileFn) {
|
|
95
|
-
const filesOnDisk = await downloadFiles(fileUrls);
|
|
96
|
-
const gridLocalFiles = await promiseMap(filesOnDisk, localFileLocation => uploadFileToGrid(localFileLocation, uploadFileFn));
|
|
97
|
-
return Array.isArray(gridLocalFiles) && gridLocalFiles.map(gridLocalFile => gridLocalFile?.value);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
module.exports = {
|
|
101
|
-
getVisibleElementScript,
|
|
102
|
-
downloadFilesAndUploadToGrid,
|
|
103
|
-
};
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
const { Log, Severity, CoralogixLogger } = require('@testim/coralogix-logger');
|
|
2
|
-
const TransportStream = require('winston-transport');
|
|
3
|
-
|
|
4
|
-
const severityMap = {
|
|
5
|
-
silly: Severity.verbose,
|
|
6
|
-
verbose: Severity.verbose,
|
|
7
|
-
info: Severity.info,
|
|
8
|
-
http: Severity.info,
|
|
9
|
-
warn: Severity.warning,
|
|
10
|
-
warning: Severity.warning,
|
|
11
|
-
error: Severity.error,
|
|
12
|
-
silent: Severity.verbose,
|
|
13
|
-
critical: Severity.critical,
|
|
14
|
-
crit: Severity.critical,
|
|
15
|
-
debug: Severity.debug,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const errorProps = ['err', 'error', 'reason', 'e'];
|
|
19
|
-
|
|
20
|
-
class CoralogixTransport extends TransportStream {
|
|
21
|
-
constructor(options) {
|
|
22
|
-
options = Object.assign({}, CoralogixTransport.options, options);
|
|
23
|
-
super(options);
|
|
24
|
-
this.options = options;
|
|
25
|
-
this.logger = new CoralogixLogger(options.category);
|
|
26
|
-
this.name = 'Coralogix Transport';
|
|
27
|
-
if (options.timestamp) {
|
|
28
|
-
this.timestamp = options.timestamp;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
log(info, callback) {
|
|
33
|
-
const { category, level, message: msg, meta: infoMeta = {}, ...restMeta } = info;
|
|
34
|
-
const meta = Object.assign({}, infoMeta, this.options.extraFields, restMeta);
|
|
35
|
-
const log = new Log();
|
|
36
|
-
|
|
37
|
-
log.severity = severityMap[level];
|
|
38
|
-
log.text = msg;
|
|
39
|
-
log.category = category;
|
|
40
|
-
if (meta.className) {
|
|
41
|
-
log.className = meta.className;
|
|
42
|
-
}
|
|
43
|
-
if (meta.methodName) {
|
|
44
|
-
log.methodName = meta.methodName;
|
|
45
|
-
}
|
|
46
|
-
if (meta.threadId) {
|
|
47
|
-
log.threadId = meta.threadId;
|
|
48
|
-
}
|
|
49
|
-
delete meta.className;
|
|
50
|
-
delete meta.methodName;
|
|
51
|
-
delete meta.threadId;
|
|
52
|
-
delete meta.category;
|
|
53
|
-
delete meta.level;
|
|
54
|
-
delete meta.message;
|
|
55
|
-
let errorOverride = false;
|
|
56
|
-
if (infoMeta instanceof Error) {
|
|
57
|
-
errorOverride = true;
|
|
58
|
-
meta.msg = infoMeta.message + infoMeta.stack;
|
|
59
|
-
if (msg) {
|
|
60
|
-
meta.msg = `${msg}\n${meta.msg}`;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
for (const prop of errorProps) {
|
|
65
|
-
if (infoMeta[prop] instanceof Error) {
|
|
66
|
-
meta[prop] = {
|
|
67
|
-
message: infoMeta[prop].message,
|
|
68
|
-
stack: infoMeta[prop].stack,
|
|
69
|
-
name: infoMeta[prop].name,
|
|
70
|
-
type: infoMeta[prop].type,
|
|
71
|
-
cause: infoMeta[prop].cause,
|
|
72
|
-
...infoMeta[prop],
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// still have keys after deleting the above
|
|
78
|
-
if (Object.keys(meta).length > 0) {
|
|
79
|
-
if (msg && !errorOverride) {
|
|
80
|
-
meta.msg = msg;
|
|
81
|
-
}
|
|
82
|
-
log.text = meta;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
this.logger.addLog(log);
|
|
86
|
-
callback(null, true);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
waitForFlush() {
|
|
90
|
-
return this.logger.waitForFlush();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
static configure(config) {
|
|
94
|
-
CoralogixLogger.configure(config);
|
|
95
|
-
CoralogixTransport.options = config;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
module.exports.CoralogixTransport = CoralogixTransport;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
const {SELENIUM_STATUS_CODES} = require('./constants');
|
|
2
|
-
|
|
3
|
-
//https://github.com/webdriverio-boneyard/v4/blob/master/lib/utils/ErrorHandler.js
|
|
4
|
-
//https://github.com/webdriverio-boneyard/v4/blob/master/LICENSE-MIT
|
|
5
|
-
class WebDriverError extends Error {
|
|
6
|
-
constructor(type, msg, details) {
|
|
7
|
-
super();
|
|
8
|
-
|
|
9
|
-
if (typeof msg === 'number') {
|
|
10
|
-
// if ID is not known error throw UnknownError
|
|
11
|
-
if (!SELENIUM_STATUS_CODES[msg]) {
|
|
12
|
-
msg = 13; // UnknownError
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
this.type = SELENIUM_STATUS_CODES[msg].id;
|
|
16
|
-
this.message = SELENIUM_STATUS_CODES[msg].message;
|
|
17
|
-
|
|
18
|
-
if (msg === 7 && details) { //NoSuchElement
|
|
19
|
-
this.message = `${this.message.slice(0, -1)} ("${details}").`;
|
|
20
|
-
}
|
|
21
|
-
} else if (arguments.length > 1) {
|
|
22
|
-
this.details = details;
|
|
23
|
-
this.message = msg;
|
|
24
|
-
this.type = type;
|
|
25
|
-
} else if (arguments.length === 1) {
|
|
26
|
-
this.type = 'TestimWebdriverError';
|
|
27
|
-
this.message = type;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* don't modify error if no response is available
|
|
32
|
-
*/
|
|
33
|
-
if (typeof this.message !== 'object') {
|
|
34
|
-
Error.captureStackTrace(this, WebDriverError);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
let seleniumStack = this.message;
|
|
39
|
-
|
|
40
|
-
if (seleniumStack.screenshot) {
|
|
41
|
-
this.screenshot = seleniumStack.screenshot;
|
|
42
|
-
delete seleniumStack.screenshot;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (seleniumStack.message && seleniumStack.type) {
|
|
46
|
-
if (typeof seleniumStack.orgStatusMessage === 'string' && seleniumStack.orgStatusMessage.match(/"errorMessage":"NoSuchElement"/)) {
|
|
47
|
-
seleniumStack.type = 'NoSuchElement';
|
|
48
|
-
seleniumStack.status = 7;
|
|
49
|
-
seleniumStack.message = SELENIUM_STATUS_CODES['7'].message;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
this.message = seleniumStack.message + ' (' + seleniumStack.type + ':' + seleniumStack.status + ')';
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (typeof seleniumStack.orgStatusMessage === 'string') {
|
|
56
|
-
let reqPos = seleniumStack.orgStatusMessage.indexOf(',"request"');
|
|
57
|
-
let problem = '';
|
|
58
|
-
|
|
59
|
-
if (reqPos > 0) {
|
|
60
|
-
problem = JSON.parse(seleniumStack.orgStatusMessage.slice(0, reqPos) + '}').errorMessage;
|
|
61
|
-
} else {
|
|
62
|
-
problem = seleniumStack.orgStatusMessage;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (problem.indexOf('No enum constant org.openqa.selenium.Platform') > -1) {
|
|
66
|
-
problem = 'The Selenium backend you\'ve chosen doesn\'t support the desired platform (' + problem.slice(46) + ')';
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// truncate errorMessage
|
|
70
|
-
if (problem.indexOf('(Session info:') > -1) {
|
|
71
|
-
problem = problem.slice(0, problem.indexOf('(Session info:')).trim();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// make assumption based on experience on certain error messages
|
|
75
|
-
if (problem.indexOf('unknown error: path is not absolute') !== -1) {
|
|
76
|
-
problem = 'You are trying to set a value to an input field with type="file", use the `uploadFile` command instead (Selenium error: ' + problem + ')';
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
this.message = problem;
|
|
80
|
-
this.seleniumStack = seleniumStack;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
Error.captureStackTrace(this, WebDriverError );
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* make stack loggable
|
|
88
|
-
* @return {Object} error log
|
|
89
|
-
*/
|
|
90
|
-
toJSON() {
|
|
91
|
-
return {
|
|
92
|
-
name: this.type,
|
|
93
|
-
message: this.message
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
module.exports = function (msg, details) {
|
|
99
|
-
return new WebDriverError('SeleniumProtocolError', msg, details);
|
|
100
|
-
};
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
//https://github.com/webdriverio-boneyard/v4/blob/master/LICENSE-MIT
|
|
2
|
-
|
|
3
|
-
const _ = require('lodash');
|
|
4
|
-
const httpRequest = require('../commons/httpRequest');
|
|
5
|
-
const utils = require('../utils');
|
|
6
|
-
const SeleniumProtocolError = require('./SeleniumProtocolError');
|
|
7
|
-
const { SELENIUM_STATUS_CODES } = require('./constants');
|
|
8
|
-
const logger = require('../commons/logger').getLogger('WebDriverHttpRequest');
|
|
9
|
-
|
|
10
|
-
function isSuccessfulResponse(body, statusCode) {
|
|
11
|
-
/**
|
|
12
|
-
* response contains a body
|
|
13
|
-
*/
|
|
14
|
-
if (!body) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* if it has a status property, it should be 0
|
|
20
|
-
* (just here to stay backwards compatible to the jsonwire protocol)
|
|
21
|
-
*/
|
|
22
|
-
if (body.status && body.status !== 0) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* the body contains an actual result
|
|
28
|
-
*/
|
|
29
|
-
if (typeof body.value === 'undefined') {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* check status code
|
|
35
|
-
*/
|
|
36
|
-
if (statusCode === 200) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* that has no error property (Appium only)
|
|
42
|
-
*/
|
|
43
|
-
if (body.value && (body.value.error || body.value.stackTrace || body.value.stacktrace)) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
class WebDriverHttpRequest {
|
|
51
|
-
constructor(gridUrl, headers, connectionRetryTimeout, testResultId) {
|
|
52
|
-
this.gridUrl = gridUrl;
|
|
53
|
-
this.headers = headers;
|
|
54
|
-
this.connectionRetryTimeout = connectionRetryTimeout;
|
|
55
|
-
this.testResultId = testResultId;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
handleFailedStatus(requestId, response, err = {}) {
|
|
59
|
-
const { body, statusCode, headers, text } = response;
|
|
60
|
-
const resBody = _.isEmpty(body) && text ? text : body;
|
|
61
|
-
/**
|
|
62
|
-
* in Appium you find sometimes more exact error messages in origValue
|
|
63
|
-
*/
|
|
64
|
-
if (resBody && resBody.value && typeof resBody.value.origValue === 'string' && typeof resBody.value.message === 'string') {
|
|
65
|
-
resBody.value.message += ` ${resBody.value.origValue}`;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (resBody && typeof resBody === 'string') {
|
|
69
|
-
throw new SeleniumProtocolError(resBody, { requestId });
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (resBody && resBody.value) {
|
|
73
|
-
const errorCode = SELENIUM_STATUS_CODES[resBody.status] || (resBody.value && SELENIUM_STATUS_CODES[resBody.value.error]) || SELENIUM_STATUS_CODES[-1];
|
|
74
|
-
const error = {
|
|
75
|
-
type: errorCode ? errorCode.id : 'unknown',
|
|
76
|
-
message: errorCode ? errorCode.message : 'unknown',
|
|
77
|
-
orgStatusMessage: resBody.value ? resBody.value.message : '',
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
throw new SeleniumProtocolError(error, { requestId });
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// IEServer webdriver bug where the error is put into the Allow header
|
|
84
|
-
// https://github.com/SeleniumHQ/selenium/issues/6828
|
|
85
|
-
if (statusCode === 405) {
|
|
86
|
-
const allowHeader = headers && headers.allow;
|
|
87
|
-
const _err = new SeleniumProtocolError(allowHeader, { requestId });
|
|
88
|
-
if (_err.message.match(/Command not found/)) {
|
|
89
|
-
throw _err;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
throw new SeleniumProtocolError({
|
|
94
|
-
status: -1,
|
|
95
|
-
type: err.code || 'ECONNREFUSED',
|
|
96
|
-
orgStatusMessage: err.rawResponse || err.message,
|
|
97
|
-
message: err.rawResponse || "Couldn't connect to selenium server",
|
|
98
|
-
}, { requestId });
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
processHttpOnSuccess(response, requestId) {
|
|
102
|
-
const { body, statusCode } = response;
|
|
103
|
-
if (isSuccessfulResponse(body, statusCode)) {
|
|
104
|
-
return body;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return this.handleFailedStatus(requestId, response);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
processHttpOnError(err, requestId) {
|
|
111
|
-
const response = (err && err.response) || {};
|
|
112
|
-
return this.handleFailedStatus(requestId, response, err);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
httpPostRequest(path, body = {}) {
|
|
116
|
-
const requestId = utils.guid();
|
|
117
|
-
if (path === '/session') {
|
|
118
|
-
logger.info('POST REQUEST', { requestId, path, testResultId: this.testResultId });
|
|
119
|
-
} else {
|
|
120
|
-
logger.info('POST REQUEST', { requestId, path, body, testResultId: this.testResultId });
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return httpRequest.postFullRes(`${this.gridUrl}${path}`, body, this.headers, this.connectionRetryTimeout)
|
|
124
|
-
.then(response => {
|
|
125
|
-
logger.info('POST RESPONSE', {
|
|
126
|
-
requestId,
|
|
127
|
-
path,
|
|
128
|
-
res: JSON.stringify(response.body),
|
|
129
|
-
testResultId: this.testResultId,
|
|
130
|
-
});
|
|
131
|
-
return response;
|
|
132
|
-
})
|
|
133
|
-
.catch(err => this.processHttpOnError(err, requestId))
|
|
134
|
-
.then((response) => this.processHttpOnSuccess(response, requestId));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
httpGetRequest(path) {
|
|
138
|
-
const requestId = utils.guid();
|
|
139
|
-
logger.info('GET REQUEST', { requestId, path, testResultId: this.testResultId });
|
|
140
|
-
const query = {};
|
|
141
|
-
return httpRequest.getFullRes(`${this.gridUrl}${path}`, query, this.headers, this.connectionRetryTimeout)
|
|
142
|
-
.then(response => {
|
|
143
|
-
if (_.endsWith(path, '/screenshot')) {
|
|
144
|
-
logger.info('GET RESPONSE', { requestId, path, testResultId: this.testResultId });
|
|
145
|
-
return response;
|
|
146
|
-
}
|
|
147
|
-
logger.info('GET RESPONSE', {
|
|
148
|
-
requestId,
|
|
149
|
-
path,
|
|
150
|
-
res: JSON.stringify(response.body),
|
|
151
|
-
testResultId: this.testResultId,
|
|
152
|
-
});
|
|
153
|
-
return response;
|
|
154
|
-
})
|
|
155
|
-
.catch(err => this.processHttpOnError(err, requestId))
|
|
156
|
-
.then((response) => this.processHttpOnSuccess(response, requestId));
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
httpDeleteRequest(path) {
|
|
160
|
-
const requestId = utils.guid();
|
|
161
|
-
logger.info('DELETE REQUEST', { requestId, path, testResultId: this.testResultId });
|
|
162
|
-
return httpRequest.deleteFullRes(`${this.gridUrl}${path}`, undefined, this.headers, this.connectionRetryTimeout)
|
|
163
|
-
.then(response => {
|
|
164
|
-
logger.info('DELETE RESPONSE', {
|
|
165
|
-
requestId,
|
|
166
|
-
path,
|
|
167
|
-
res: JSON.stringify(response.body),
|
|
168
|
-
testResultId: this.testResultId,
|
|
169
|
-
});
|
|
170
|
-
return response;
|
|
171
|
-
})
|
|
172
|
-
.catch(err => this.processHttpOnError(err, requestId))
|
|
173
|
-
.then((response) => this.processHttpOnSuccess(response, requestId));
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
module.exports = WebDriverHttpRequest;
|