@browserstack/testcafe
Version:
Automated browser testing for the modern web development stack.
984 lines (969 loc) • 218 kB
JavaScript
// NOTE: We should have the capability to initialize scripts with different contexts.
// This is required for iframes without the src attribute because Hammerhead does not
// inject scripts into such iframes. So, we wrap all scripts in initialization functions.
(function () {
function initTestCafeClientDrivers(window, isIFrameWithoutSrc) {
var document = window.document;
(function (hammerhead, testCafeCore, testcafeAutomation, testcafeUi) {
var hammerhead__default = 'default' in hammerhead ? hammerhead['default'] : hammerhead;
var testCafeCore__default = 'default' in testCafeCore ? testCafeCore['default'] : testCafeCore;
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
// -------------------------------------------------------------
// WARNING: this file is used by both the client and the server.
// Do not use any browser or node-specific API!
// -------------------------------------------------------------
var HEARTBEAT_TIMEOUT = 7 * 60 * 1000;
var CHECK_IFRAME_DRIVER_LINK_DELAY = 500;
var CHECK_CHILD_WINDOW_DRIVER_LINK_DELAY = 500;
var SEND_STATUS_REQUEST_TIME_LIMIT = 5000;
var SEND_STATUS_REQUEST_RETRY_DELAY = 300;
var SEND_STATUS_REQUEST_RETRY_COUNT = Math.floor(HEARTBEAT_TIMEOUT / SEND_STATUS_REQUEST_RETRY_DELAY - 1);
var CHECK_STATUS_RETRY_DELAY = 1000;
var TEST_RUN_MESSAGES = {
ready: 'ready',
readyForBrowserManipulation: 'ready-for-browser-manipulation',
waitForFileDownload: 'wait-for-file-download'
};
// -------------------------------------------------------------
// WARNING: this file is used by both the client and the server.
// Do not use any browser or node-specific API!
// -------------------------------------------------------------
var COMMAND_TYPE = {
click: 'click',
rightClick: 'right-click',
doubleClick: 'double-click',
drag: 'drag',
dragToElement: 'drag-to-element',
hover: 'hover',
typeText: 'type-text',
selectText: 'select-text',
selectTextAreaContent: 'select-text-area-content',
selectEditableContent: 'select-editable-content',
pressKey: 'press-key',
wait: 'wait',
navigateTo: 'navigate-to',
setFilesToUpload: 'set-files-to-upload',
clearUpload: 'clear-upload',
executeClientFunction: 'execute-client-function',
executeSelector: 'execute-selector',
takeScreenshot: 'take-screenshot',
takeElementScreenshot: 'take-element-screenshot',
takeScreenshotOnFail: 'take-screenshot-on-fail',
prepareBrowserManipulation: 'prepare-browser-manipulation',
showAssertionRetriesStatus: 'show-assertion-retries-status',
hideAssertionRetriesStatus: 'hide-assertion-retries-status',
setBreakpoint: 'set-breakpoint',
resizeWindow: 'resize-window',
resizeWindowToFitDevice: 'resize-window-to-fit-device',
maximizeWindow: 'maximize-window',
switchToIframe: 'switch-to-iframe',
switchToMainWindow: 'switch-to-main-window',
setNativeDialogHandler: 'set-native-dialog-handler',
getNativeDialogHistory: 'get-native-dialog-history',
getBrowserConsoleMessages: 'get-browser-console-messages',
setTestSpeed: 'set-test-speed',
setPageLoadTimeout: 'set-page-load-timeout',
debug: 'debug',
assertion: 'assertion',
useRole: 'useRole',
testDone: 'test-done',
backupStorages: 'backup-storages',
executeExpression: 'execute-expression',
executeAsyncExpression: 'execute-async-expression',
unlockPage: 'unlock-page',
recorder: 'recorder'
};
// -------------------------------------------------------------
function isCommandRejectableByPageError(command) {
return !isObservationCommand(command) && !isBrowserManipulationCommand(command) && !isServiceCommand(command) ||
isResizeWindowCommand(command)
&& !isWindowSwitchingCommand(command);
}
function isClientFunctionCommand(command) {
return command.type === COMMAND_TYPE.executeClientFunction ||
command.type === COMMAND_TYPE.executeSelector;
}
function isObservationCommand(command) {
return isClientFunctionCommand(command) ||
command.type === COMMAND_TYPE.wait ||
command.type === COMMAND_TYPE.assertion ||
command.type === COMMAND_TYPE.executeExpression;
}
function isWindowSwitchingCommand(command) {
return command.type === COMMAND_TYPE.switchToIframe || command.type === COMMAND_TYPE.switchToMainWindow;
}
function isScreenshotCommand(command) {
return command.type === COMMAND_TYPE.takeScreenshot ||
command.type === COMMAND_TYPE.takeElementScreenshot ||
command.type === COMMAND_TYPE.takeScreenshotOnFail;
}
function isResizeWindowCommand(command) {
return command.type === COMMAND_TYPE.resizeWindow ||
command.type === COMMAND_TYPE.resizeWindowToFitDevice ||
command.type === COMMAND_TYPE.maximizeWindow;
}
function isBrowserManipulationCommand(command) {
return isScreenshotCommand(command) || isResizeWindowCommand(command);
}
function isServiceCommand(command) {
return command.type === COMMAND_TYPE.testDone ||
command.type === COMMAND_TYPE.showAssertionRetriesStatus ||
command.type === COMMAND_TYPE.hideAssertionRetriesStatus ||
command.type === COMMAND_TYPE.setBreakpoint ||
command.type === COMMAND_TYPE.takeScreenshotOnFail ||
command.type === COMMAND_TYPE.recorder;
}
function isExecutableInTopWindowOnly(command) {
return command.type === COMMAND_TYPE.testDone ||
command.type === COMMAND_TYPE.switchToMainWindow ||
command.type === COMMAND_TYPE.setNativeDialogHandler ||
command.type === COMMAND_TYPE.getNativeDialogHistory ||
command.type === COMMAND_TYPE.setTestSpeed ||
command.type === COMMAND_TYPE.showAssertionRetriesStatus ||
command.type === COMMAND_TYPE.hideAssertionRetriesStatus ||
command.type === COMMAND_TYPE.setBreakpoint ||
isBrowserManipulationCommand(command) && command.type !== COMMAND_TYPE.takeElementScreenshot;
}
// -------------------------------------------------------------
// WARNING: this file is used by both the client and the server.
// Do not use any browser or node-specific API!
// -------------------------------------------------------------
var TEST_RUN_ERRORS = {
uncaughtErrorOnPage: 'E1',
uncaughtErrorInTestCode: 'E2',
uncaughtNonErrorObjectInTestCode: 'E3',
uncaughtErrorInClientFunctionCode: 'E4',
uncaughtErrorInCustomDOMPropertyCode: 'E5',
unhandledPromiseRejection: 'E6',
uncaughtException: 'E7',
missingAwaitError: 'E8',
actionIntegerOptionError: 'E9',
actionPositiveIntegerOptionError: 'E10',
actionBooleanOptionError: 'E11',
actionSpeedOptionError: 'E12',
actionOptionsTypeError: 'E14',
actionBooleanArgumentError: 'E15',
actionStringArgumentError: 'E16',
actionNullableStringArgumentError: 'E17',
actionStringOrStringArrayArgumentError: 'E18',
actionStringArrayElementError: 'E19',
actionIntegerArgumentError: 'E20',
actionRoleArgumentError: 'E21',
actionPositiveIntegerArgumentError: 'E22',
actionSelectorError: 'E23',
actionElementNotFoundError: 'E24',
actionElementIsInvisibleError: 'E26',
actionSelectorMatchesWrongNodeTypeError: 'E27',
actionAdditionalElementNotFoundError: 'E28',
actionAdditionalElementIsInvisibleError: 'E29',
actionAdditionalSelectorMatchesWrongNodeTypeError: 'E30',
actionElementNonEditableError: 'E31',
actionElementNotTextAreaError: 'E32',
actionElementNonContentEditableError: 'E33',
actionElementIsNotFileInputError: 'E34',
actionRootContainerNotFoundError: 'E35',
actionIncorrectKeysError: 'E36',
actionCannotFindFileToUploadError: 'E37',
actionUnsupportedDeviceTypeError: 'E38',
actionIframeIsNotLoadedError: 'E39',
actionElementNotIframeError: 'E40',
actionInvalidScrollTargetError: 'E41',
currentIframeIsNotLoadedError: 'E42',
currentIframeNotFoundError: 'E43',
currentIframeIsInvisibleError: 'E44',
nativeDialogNotHandledError: 'E45',
uncaughtErrorInNativeDialogHandler: 'E46',
setTestSpeedArgumentError: 'E47',
setNativeDialogHandlerCodeWrongTypeError: 'E48',
clientFunctionExecutionInterruptionError: 'E49',
domNodeClientFunctionResultError: 'E50',
invalidSelectorResultError: 'E51',
cannotObtainInfoForElementSpecifiedBySelectorError: 'E52',
externalAssertionLibraryError: 'E53',
pageLoadError: 'E54',
windowDimensionsOverflowError: 'E55',
forbiddenCharactersInScreenshotPathError: 'E56',
invalidElementScreenshotDimensionsError: 'E57',
roleSwitchInRoleInitializerError: 'E58',
assertionExecutableArgumentError: 'E59',
assertionWithoutMethodCallError: 'E60',
assertionUnawaitedPromiseError: 'E61',
requestHookNotImplementedError: 'E62',
requestHookUnhandledError: 'E63',
uncaughtErrorInCustomClientScriptCode: 'E64',
uncaughtErrorInCustomClientScriptCodeLoadedFromModule: 'E65',
uncaughtErrorInCustomScript: 'E66',
uncaughtTestCafeErrorInCustomScript: 'E67',
childWindowIsNotLoadedError: 'E68',
childWindowNotFoundError: 'E69',
cannotSwitchToWindowError: 'E70',
closeChildWindowError: 'E71',
childWindowClosedBeforeSwitchingError: 'E72'
};
// Base
//--------------------------------------------------------------------
var TestRunErrorBase = /** @class */ (function () {
function TestRunErrorBase(code) {
this.code = code;
this.isTestCafeError = true;
this.callsite = null;
}
return TestRunErrorBase;
}());
var ActionOptionErrorBase = /** @class */ (function (_super) {
__extends(ActionOptionErrorBase, _super);
function ActionOptionErrorBase(code, optionName, actualValue) {
var _this = _super.call(this, code) || this;
_this.optionName = optionName;
_this.actualValue = actualValue;
return _this;
}
return ActionOptionErrorBase;
}(TestRunErrorBase));
var ActionArgumentErrorBase = /** @class */ (function (_super) {
__extends(ActionArgumentErrorBase, _super);
function ActionArgumentErrorBase(code, argumentName, actualValue) {
var _this = _super.call(this, code) || this;
_this.argumentName = argumentName;
_this.actualValue = actualValue;
return _this;
}
return ActionArgumentErrorBase;
}(TestRunErrorBase));
// Synchronization errors
//--------------------------------------------------------------------
var MissingAwaitError = /** @class */ (function (_super) {
__extends(MissingAwaitError, _super);
function MissingAwaitError(callsite) {
var _this = _super.call(this, TEST_RUN_ERRORS.missingAwaitError) || this;
_this.callsite = callsite;
return _this;
}
return MissingAwaitError;
}(TestRunErrorBase));
// Client function errors
//--------------------------------------------------------------------
var ClientFunctionExecutionInterruptionError = /** @class */ (function (_super) {
__extends(ClientFunctionExecutionInterruptionError, _super);
function ClientFunctionExecutionInterruptionError(instantiationCallsiteName) {
var _this = _super.call(this, TEST_RUN_ERRORS.clientFunctionExecutionInterruptionError) || this;
_this.instantiationCallsiteName = instantiationCallsiteName;
return _this;
}
return ClientFunctionExecutionInterruptionError;
}(TestRunErrorBase));
var DomNodeClientFunctionResultError = /** @class */ (function (_super) {
__extends(DomNodeClientFunctionResultError, _super);
function DomNodeClientFunctionResultError(instantiationCallsiteName) {
var _this = _super.call(this, TEST_RUN_ERRORS.domNodeClientFunctionResultError) || this;
_this.instantiationCallsiteName = instantiationCallsiteName;
return _this;
}
return DomNodeClientFunctionResultError;
}(TestRunErrorBase));
// Selector errors
//--------------------------------------------------------------------
var SelectorErrorBase = /** @class */ (function (_super) {
__extends(SelectorErrorBase, _super);
function SelectorErrorBase(code, _a) {
var apiFnChain = _a.apiFnChain, apiFnIndex = _a.apiFnIndex;
var _this = _super.call(this, code) || this;
_this.apiFnChain = apiFnChain;
_this.apiFnIndex = apiFnIndex;
return _this;
}
return SelectorErrorBase;
}(TestRunErrorBase));
var InvalidSelectorResultError = /** @class */ (function (_super) {
__extends(InvalidSelectorResultError, _super);
function InvalidSelectorResultError() {
return _super.call(this, TEST_RUN_ERRORS.invalidSelectorResultError) || this;
}
return InvalidSelectorResultError;
}(TestRunErrorBase));
var CannotObtainInfoForElementSpecifiedBySelectorError = /** @class */ (function (_super) {
__extends(CannotObtainInfoForElementSpecifiedBySelectorError, _super);
function CannotObtainInfoForElementSpecifiedBySelectorError(callsite, apiFnArgs) {
var _this = _super.call(this, TEST_RUN_ERRORS.cannotObtainInfoForElementSpecifiedBySelectorError, apiFnArgs) || this;
_this.callsite = callsite;
return _this;
}
return CannotObtainInfoForElementSpecifiedBySelectorError;
}(SelectorErrorBase));
// Page errors
//--------------------------------------------------------------------
var PageLoadError = /** @class */ (function (_super) {
__extends(PageLoadError, _super);
function PageLoadError(errMsg, url) {
var _this = _super.call(this, TEST_RUN_ERRORS.pageLoadError) || this;
_this.url = url;
_this.errMsg = errMsg;
return _this;
}
return PageLoadError;
}(TestRunErrorBase));
// Uncaught errors
//--------------------------------------------------------------------
var UncaughtErrorOnPage = /** @class */ (function (_super) {
__extends(UncaughtErrorOnPage, _super);
function UncaughtErrorOnPage(errStack, pageDestUrl) {
var _this = _super.call(this, TEST_RUN_ERRORS.uncaughtErrorOnPage) || this;
_this.errStack = errStack;
_this.pageDestUrl = pageDestUrl;
return _this;
}
return UncaughtErrorOnPage;
}(TestRunErrorBase));
var UncaughtErrorInTestCode = /** @class */ (function (_super) {
__extends(UncaughtErrorInTestCode, _super);
function UncaughtErrorInTestCode(err, callsite) {
var _this = _super.call(this, TEST_RUN_ERRORS.uncaughtErrorInTestCode) || this;
_this.errMsg = String(err.rawMessage || err);
_this.callsite = err.callsite || callsite;
_this.originError = err;
return _this;
}
return UncaughtErrorInTestCode;
}(TestRunErrorBase));
var UncaughtNonErrorObjectInTestCode = /** @class */ (function (_super) {
__extends(UncaughtNonErrorObjectInTestCode, _super);
function UncaughtNonErrorObjectInTestCode(obj) {
var _this = _super.call(this, TEST_RUN_ERRORS.uncaughtNonErrorObjectInTestCode) || this;
_this.objType = typeof obj;
_this.objStr = String(obj);
return _this;
}
return UncaughtNonErrorObjectInTestCode;
}(TestRunErrorBase));
var UncaughtErrorInClientFunctionCode = /** @class */ (function (_super) {
__extends(UncaughtErrorInClientFunctionCode, _super);
function UncaughtErrorInClientFunctionCode(instantiationCallsiteName, err) {
var _this = _super.call(this, TEST_RUN_ERRORS.uncaughtErrorInClientFunctionCode) || this;
_this.errMsg = String(err);
_this.instantiationCallsiteName = instantiationCallsiteName;
return _this;
}
return UncaughtErrorInClientFunctionCode;
}(TestRunErrorBase));
var UncaughtErrorInCustomDOMPropertyCode = /** @class */ (function (_super) {
__extends(UncaughtErrorInCustomDOMPropertyCode, _super);
function UncaughtErrorInCustomDOMPropertyCode(instantiationCallsiteName, err, prop) {
var _this = _super.call(this, TEST_RUN_ERRORS.uncaughtErrorInCustomDOMPropertyCode, err, prop) || this;
_this.errMsg = String(err);
_this.property = prop;
_this.instantiationCallsiteName = instantiationCallsiteName;
return _this;
}
return UncaughtErrorInCustomDOMPropertyCode;
}(TestRunErrorBase));
var UnhandledPromiseRejectionError = /** @class */ (function (_super) {
__extends(UnhandledPromiseRejectionError, _super);
function UnhandledPromiseRejectionError(err) {
var _this = _super.call(this, TEST_RUN_ERRORS.unhandledPromiseRejection) || this;
_this.errMsg = String(err);
return _this;
}
return UnhandledPromiseRejectionError;
}(TestRunErrorBase));
var UncaughtExceptionError = /** @class */ (function (_super) {
__extends(UncaughtExceptionError, _super);
function UncaughtExceptionError(err) {
var _this = _super.call(this, TEST_RUN_ERRORS.uncaughtException) || this;
_this.errMsg = String(err);
return _this;
}
return UncaughtExceptionError;
}(TestRunErrorBase));
var UncaughtErrorInCustomClientScriptCode = /** @class */ (function (_super) {
__extends(UncaughtErrorInCustomClientScriptCode, _super);
function UncaughtErrorInCustomClientScriptCode(err) {
var _this = _super.call(this, TEST_RUN_ERRORS.uncaughtErrorInCustomClientScriptCode) || this;
_this.errMsg = String(err);
return _this;
}
return UncaughtErrorInCustomClientScriptCode;
}(TestRunErrorBase));
var UncaughtErrorInCustomClientScriptLoadedFromModule = /** @class */ (function (_super) {
__extends(UncaughtErrorInCustomClientScriptLoadedFromModule, _super);
function UncaughtErrorInCustomClientScriptLoadedFromModule(err, moduleName) {
var _this = _super.call(this, TEST_RUN_ERRORS.uncaughtErrorInCustomClientScriptCodeLoadedFromModule) || this;
_this.errMsg = String(err);
_this.moduleName = moduleName;
return _this;
}
return UncaughtErrorInCustomClientScriptLoadedFromModule;
}(TestRunErrorBase));
// Assertion errors
//--------------------------------------------------------------------
var ExternalAssertionLibraryError = /** @class */ (function (_super) {
__extends(ExternalAssertionLibraryError, _super);
function ExternalAssertionLibraryError(err, callsite) {
var _this = _super.call(this, TEST_RUN_ERRORS.externalAssertionLibraryError) || this;
_this.errMsg = String(err);
_this.callsite = callsite;
return _this;
}
return ExternalAssertionLibraryError;
}(TestRunErrorBase));
var AssertionExecutableArgumentError = /** @class */ (function (_super) {
__extends(AssertionExecutableArgumentError, _super);
function AssertionExecutableArgumentError(argumentName, argumentValue, err, isAPIError) {
var _this = _super.call(this, TEST_RUN_ERRORS.assertionExecutableArgumentError, argumentName, argumentValue) || this;
_this.errMsg = isAPIError ? err.rawMessage : err.message;
_this.originError = err;
return _this;
}
return AssertionExecutableArgumentError;
}(ActionArgumentErrorBase));
var AssertionWithoutMethodCallError = /** @class */ (function (_super) {
__extends(AssertionWithoutMethodCallError, _super);
function AssertionWithoutMethodCallError(callsite) {
var _this = _super.call(this, TEST_RUN_ERRORS.assertionWithoutMethodCallError) || this;
_this.callsite = callsite;
return _this;
}
return AssertionWithoutMethodCallError;
}(TestRunErrorBase));
var AssertionUnawaitedPromiseError = /** @class */ (function (_super) {
__extends(AssertionUnawaitedPromiseError, _super);
function AssertionUnawaitedPromiseError(callsite) {
var _this = _super.call(this, TEST_RUN_ERRORS.assertionUnawaitedPromiseError) || this;
_this.callsite = callsite;
return _this;
}
return AssertionUnawaitedPromiseError;
}(TestRunErrorBase));
// Action parameters errors
//--------------------------------------------------------------------
// Options errors
var ActionIntegerOptionError = /** @class */ (function (_super) {
__extends(ActionIntegerOptionError, _super);
function ActionIntegerOptionError(optionName, actualValue) {
return _super.call(this, TEST_RUN_ERRORS.actionIntegerOptionError, optionName, actualValue) || this;
}
return ActionIntegerOptionError;
}(ActionOptionErrorBase));
var ActionPositiveIntegerOptionError = /** @class */ (function (_super) {
__extends(ActionPositiveIntegerOptionError, _super);
function ActionPositiveIntegerOptionError(optionName, actualValue) {
return _super.call(this, TEST_RUN_ERRORS.actionPositiveIntegerOptionError, optionName, actualValue) || this;
}
return ActionPositiveIntegerOptionError;
}(ActionOptionErrorBase));
var ActionBooleanOptionError = /** @class */ (function (_super) {
__extends(ActionBooleanOptionError, _super);
function ActionBooleanOptionError(optionName, actualValue) {
return _super.call(this, TEST_RUN_ERRORS.actionBooleanOptionError, optionName, actualValue) || this;
}
return ActionBooleanOptionError;
}(ActionOptionErrorBase));
var ActionBooleanArgumentError = /** @class */ (function (_super) {
__extends(ActionBooleanArgumentError, _super);
function ActionBooleanArgumentError(argumentName, actualValue) {
return _super.call(this, TEST_RUN_ERRORS.actionBooleanArgumentError, argumentName, actualValue) || this;
}
return ActionBooleanArgumentError;
}(ActionArgumentErrorBase));
var ActionSpeedOptionError = /** @class */ (function (_super) {
__extends(ActionSpeedOptionError, _super);
function ActionSpeedOptionError(optionName, actualValue) {
return _super.call(this, TEST_RUN_ERRORS.actionSpeedOptionError, optionName, actualValue) || this;
}
return ActionSpeedOptionError;
}(ActionOptionErrorBase));
var ActionOptionsTypeError = /** @class */ (function (_super) {
__extends(ActionOptionsTypeError, _super);
function ActionOptionsTypeError(actualType) {
var _this = _super.call(this, TEST_RUN_ERRORS.actionOptionsTypeError) || this;
_this.actualType = actualType;
return _this;
}
return ActionOptionsTypeError;
}(TestRunErrorBase));
// Arguments errors
var ActionStringArgumentError = /** @class */ (function (_super) {
__extends(ActionStringArgumentError, _super);
function ActionStringArgumentError(argumentName, actualValue) {
return _super.call(this, TEST_RUN_ERRORS.actionStringArgumentError, argumentName, actualValue) || this;
}
return ActionStringArgumentError;
}(ActionArgumentErrorBase));
var ActionNullableStringArgumentError = /** @class */ (function (_super) {
__extends(ActionNullableStringArgumentError, _super);
function ActionNullableStringArgumentError(argumentName, actualValue) {
return _super.call(this, TEST_RUN_ERRORS.actionNullableStringArgumentError, argumentName, actualValue) || this;
}
return ActionNullableStringArgumentError;
}(ActionArgumentErrorBase));
var ActionIntegerArgumentError = /** @class */ (function (_super) {
__extends(ActionIntegerArgumentError, _super);
function ActionIntegerArgumentError(argumentName, actualValue) {
return _super.call(this, TEST_RUN_ERRORS.actionIntegerArgumentError, argumentName, actualValue) || this;
}
return ActionIntegerArgumentError;
}(ActionArgumentErrorBase));
var ActionRoleArgumentError = /** @class */ (function (_super) {
__extends(ActionRoleArgumentError, _super);
function ActionRoleArgumentError(argumentName, actualValue) {
return _super.call(this, TEST_RUN_ERRORS.actionRoleArgumentError, argumentName, actualValue) || this;
}
return ActionRoleArgumentError;
}(ActionArgumentErrorBase));
var ActionPositiveIntegerArgumentError = /** @class */ (function (_super) {
__extends(ActionPositiveIntegerArgumentError, _super);
function ActionPositiveIntegerArgumentError(argumentName, actualValue) {
return _super.call(this, TEST_RUN_ERRORS.actionPositiveIntegerArgumentError, argumentName, actualValue) || this;
}
return ActionPositiveIntegerArgumentError;
}(ActionArgumentErrorBase));
var ActionStringOrStringArrayArgumentError = /** @class */ (function (_super) {
__extends(ActionStringOrStringArrayArgumentError, _super);
function ActionStringOrStringArrayArgumentError(argumentName, actualValue) {
return _super.call(this, TEST_RUN_ERRORS.actionStringOrStringArrayArgumentError, argumentName, actualValue) || this;
}
return ActionStringOrStringArrayArgumentError;
}(ActionArgumentErrorBase));
var ActionStringArrayElementError = /** @class */ (function (_super) {
__extends(ActionStringArrayElementError, _super);
function ActionStringArrayElementError(argumentName, actualValue, elementIndex) {
var _this = _super.call(this, TEST_RUN_ERRORS.actionStringArrayElementError, argumentName, actualValue) || this;
_this.elementIndex = elementIndex;
return _this;
}
return ActionStringArrayElementError;
}(ActionArgumentErrorBase));
var SetTestSpeedArgumentError = /** @class */ (function (_super) {
__extends(SetTestSpeedArgumentError, _super);
function SetTestSpeedArgumentError(argumentName, actualValue) {
return _super.call(this, TEST_RUN_ERRORS.setTestSpeedArgumentError, argumentName, actualValue) || this;
}
return SetTestSpeedArgumentError;
}(ActionArgumentErrorBase));
var ActionUnsupportedDeviceTypeError = /** @class */ (function (_super) {
__extends(ActionUnsupportedDeviceTypeError, _super);
function ActionUnsupportedDeviceTypeError(argumentName, argumentValue) {
return _super.call(this, TEST_RUN_ERRORS.actionUnsupportedDeviceTypeError, argumentName, argumentValue) || this;
}
return ActionUnsupportedDeviceTypeError;
}(ActionArgumentErrorBase));
// Selector errors
var ActionSelectorError = /** @class */ (function (_super) {
__extends(ActionSelectorError, _super);
function ActionSelectorError(selectorName, err, isAPIError) {
var _this = _super.call(this, TEST_RUN_ERRORS.actionSelectorError) || this;
_this.selectorName = selectorName;
_this.errMsg = isAPIError ? err.rawMessage : err.message;
_this.originError = err;
return _this;
}
return ActionSelectorError;
}(TestRunErrorBase));
// Action execution errors
//--------------------------------------------------------------------
var ActionElementNotFoundError = /** @class */ (function (_super) {
__extends(ActionElementNotFoundError, _super);
function ActionElementNotFoundError(apiFnArgs) {
return _super.call(this, TEST_RUN_ERRORS.actionElementNotFoundError, apiFnArgs) || this;
}
return ActionElementNotFoundError;
}(SelectorErrorBase));
var ActionElementIsInvisibleError = /** @class */ (function (_super) {
__extends(ActionElementIsInvisibleError, _super);
function ActionElementIsInvisibleError() {
return _super.call(this, TEST_RUN_ERRORS.actionElementIsInvisibleError) || this;
}
return ActionElementIsInvisibleError;
}(TestRunErrorBase));
var ActionSelectorMatchesWrongNodeTypeError = /** @class */ (function (_super) {
__extends(ActionSelectorMatchesWrongNodeTypeError, _super);
function ActionSelectorMatchesWrongNodeTypeError(nodeDescription) {
var _this = _super.call(this, TEST_RUN_ERRORS.actionSelectorMatchesWrongNodeTypeError) || this;
_this.nodeDescription = nodeDescription;
return _this;
}
return ActionSelectorMatchesWrongNodeTypeError;
}(TestRunErrorBase));
var ActionAdditionalElementNotFoundError = /** @class */ (function (_super) {
__extends(ActionAdditionalElementNotFoundError, _super);
function ActionAdditionalElementNotFoundError(argumentName, apiFnArgs) {
var _this = _super.call(this, TEST_RUN_ERRORS.actionAdditionalElementNotFoundError, apiFnArgs) || this;
_this.argumentName = argumentName;
return _this;
}
return ActionAdditionalElementNotFoundError;
}(SelectorErrorBase));
var ActionAdditionalElementIsInvisibleError = /** @class */ (function (_super) {
__extends(ActionAdditionalElementIsInvisibleError, _super);
function ActionAdditionalElementIsInvisibleError(argumentName) {
var _this = _super.call(this, TEST_RUN_ERRORS.actionAdditionalElementIsInvisibleError) || this;
_this.argumentName = argumentName;
return _this;
}
return ActionAdditionalElementIsInvisibleError;
}(TestRunErrorBase));
var ActionAdditionalSelectorMatchesWrongNodeTypeError = /** @class */ (function (_super) {
__extends(ActionAdditionalSelectorMatchesWrongNodeTypeError, _super);
function ActionAdditionalSelectorMatchesWrongNodeTypeError(argumentName, nodeDescription) {
var _this = _super.call(this, TEST_RUN_ERRORS.actionAdditionalSelectorMatchesWrongNodeTypeError) || this;
_this.argumentName = argumentName;
_this.nodeDescription = nodeDescription;
return _this;
}
return ActionAdditionalSelectorMatchesWrongNodeTypeError;
}(TestRunErrorBase));
var ActionElementNonEditableError = /** @class */ (function (_super) {
__extends(ActionElementNonEditableError, _super);
function ActionElementNonEditableError() {
return _super.call(this, TEST_RUN_ERRORS.actionElementNonEditableError) || this;
}
return ActionElementNonEditableError;
}(TestRunErrorBase));
var ActionElementNotTextAreaError = /** @class */ (function (_super) {
__extends(ActionElementNotTextAreaError, _super);
function ActionElementNotTextAreaError() {
return _super.call(this, TEST_RUN_ERRORS.actionElementNotTextAreaError) || this;
}
return ActionElementNotTextAreaError;
}(TestRunErrorBase));
var ActionElementNonContentEditableError = /** @class */ (function (_super) {
__extends(ActionElementNonContentEditableError, _super);
function ActionElementNonContentEditableError(argumentName) {
var _this = _super.call(this, TEST_RUN_ERRORS.actionElementNonContentEditableError) || this;
_this.argumentName = argumentName;
return _this;
}
return ActionElementNonContentEditableError;
}(TestRunErrorBase));
var ActionRootContainerNotFoundError = /** @class */ (function (_super) {
__extends(ActionRootContainerNotFoundError, _super);
function ActionRootContainerNotFoundError() {
return _super.call(this, TEST_RUN_ERRORS.actionRootContainerNotFoundError) || this;
}
return ActionRootContainerNotFoundError;
}(TestRunErrorBase));
var ActionIncorrectKeysError = /** @class */ (function (_super) {
__extends(ActionIncorrectKeysError, _super);
function ActionIncorrectKeysError(argumentName) {
var _this = _super.call(this, TEST_RUN_ERRORS.actionIncorrectKeysError) || this;
_this.argumentName = argumentName;
return _this;
}
return ActionIncorrectKeysError;
}(TestRunErrorBase));
var ActionCannotFindFileToUploadError = /** @class */ (function (_super) {
__extends(ActionCannotFindFileToUploadError, _super);
function ActionCannotFindFileToUploadError(filePaths, scannedFilePaths) {
var _this = _super.call(this, TEST_RUN_ERRORS.actionCannotFindFileToUploadError) || this;
_this.filePaths = filePaths;
_this.scannedFilePaths = scannedFilePaths;
return _this;
}
return ActionCannotFindFileToUploadError;
}(TestRunErrorBase));
var ActionElementIsNotFileInputError = /** @class */ (function (_super) {
__extends(ActionElementIsNotFileInputError, _super);
function ActionElementIsNotFileInputError() {
return _super.call(this, TEST_RUN_ERRORS.actionElementIsNotFileInputError) || this;
}
return ActionElementIsNotFileInputError;
}(TestRunErrorBase));
var ActionInvalidScrollTargetError = /** @class */ (function (_super) {
__extends(ActionInvalidScrollTargetError, _super);
function ActionInvalidScrollTargetError(scrollTargetXValid, scrollTargetYValid) {
var _this = _super.call(this, TEST_RUN_ERRORS.actionInvalidScrollTargetError) || this;
if (!scrollTargetXValid) {
if (!scrollTargetYValid)
_this.properties = 'scrollTargetX and scrollTargetY properties';
else
_this.properties = 'scrollTargetX property';
}
else
_this.properties = 'scrollTargetY property';
return _this;
}
return ActionInvalidScrollTargetError;
}(TestRunErrorBase));
var UncaughtErrorInCustomScript = /** @class */ (function (_super) {
__extends(UncaughtErrorInCustomScript, _super);
function UncaughtErrorInCustomScript(err, expression, line, column, callsite) {
var _this = _super.call(this, TEST_RUN_ERRORS.uncaughtErrorInCustomScript) || this;
_this.callsite = callsite;
_this.expression = expression;
_this.line = line;
_this.column = column;
_this.originError = err;
_this.errMsg = err.message || String(err);
return _this;
}
return UncaughtErrorInCustomScript;
}(TestRunErrorBase));
var UncaughtTestCafeErrorInCustomScript = /** @class */ (function (_super) {
__extends(UncaughtTestCafeErrorInCustomScript, _super);
function UncaughtTestCafeErrorInCustomScript(err, expression, line, column, callsite) {
var _this = _super.call(this, TEST_RUN_ERRORS.uncaughtTestCafeErrorInCustomScript) || this;
_this.callsite = callsite;
_this.expression = expression;
_this.line = line;
_this.column = column;
_this.originError = err;
_this.errCallsite = err.callsite;
return _this;
}
return UncaughtTestCafeErrorInCustomScript;
}(TestRunErrorBase));
var WindowDimensionsOverflowError = /** @class */ (function (_super) {
__extends(WindowDimensionsOverflowError, _super);
function WindowDimensionsOverflowError(callsite) {
var _this = _super.call(this, TEST_RUN_ERRORS.windowDimensionsOverflowError) || this;
_this.callsite = callsite;
return _this;
}
return WindowDimensionsOverflowError;
}(TestRunErrorBase));
var InvalidElementScreenshotDimensionsError = /** @class */ (function (_super) {
__extends(InvalidElementScreenshotDimensionsError, _super);
function InvalidElementScreenshotDimensionsError(width, height) {
var _this = _super.call(this, TEST_RUN_ERRORS.invalidElementScreenshotDimensionsError) || this;
var widthIsInvalid = width <= 0;
var heightIsInvalid = height <= 0;
if (widthIsInvalid) {
if (heightIsInvalid) {
_this.verb = 'are';
_this.dimensions = 'width and height';
}
else {
_this.verb = 'is';
_this.dimensions = 'width';
}
}
else {
_this.verb = 'is';
_this.dimensions = 'height';
}
return _this;
}
return InvalidElementScreenshotDimensionsError;
}(TestRunErrorBase));
var ForbiddenCharactersInScreenshotPathError = /** @class */ (function (_super) {
__extends(ForbiddenCharactersInScreenshotPathError, _super);
function ForbiddenCharactersInScreenshotPathError(screenshotPath, forbiddenCharsList) {
var _this = _super.call(this, TEST_RUN_ERRORS.forbiddenCharactersInScreenshotPathError) || this;
_this.screenshotPath = screenshotPath;
_this.forbiddenCharsList = forbiddenCharsList;
return _this;
}
return ForbiddenCharactersInScreenshotPathError;
}(TestRunErrorBase));
var RoleSwitchInRoleInitializerError = /** @class */ (function (_super) {
__extends(RoleSwitchInRoleInitializerError, _super);
function RoleSwitchInRoleInitializerError(callsite) {
var _this = _super.call(this, TEST_RUN_ERRORS.roleSwitchInRoleInitializerError) || this;
_this.callsite = callsite;
return _this;
}
return RoleSwitchInRoleInitializerError;
}(TestRunErrorBase));
// Iframe errors
var ActionElementNotIframeError = /** @class */ (function (_super) {
__extends(ActionElementNotIframeError, _super);
function ActionElementNotIframeError() {
return _super.call(this, TEST_RUN_ERRORS.actionElementNotIframeError) || this;
}
return ActionElementNotIframeError;
}(TestRunErrorBase));
var ActionIframeIsNotLoadedError = /** @class */ (function (_super) {
__extends(ActionIframeIsNotLoadedError, _super);
function ActionIframeIsNotLoadedError() {
return _super.call(this, TEST_RUN_ERRORS.actionIframeIsNotLoadedError) || this;
}
return ActionIframeIsNotLoadedError;
}(TestRunErrorBase));
var CurrentIframeIsNotLoadedError = /** @class */ (function (_super) {
__extends(CurrentIframeIsNotLoadedError, _super);
function CurrentIframeIsNotLoadedError() {
return _super.call(this, TEST_RUN_ERRORS.currentIframeIsNotLoadedError) || this;
}
return CurrentIframeIsNotLoadedError;
}(TestRunErrorBase));
var ChildWindowNotFoundError = /** @class */ (function (_super) {
__extends(ChildWindowNotFoundError, _super);
function ChildWindowNotFoundError() {
return _super.call(this, TEST_RUN_ERRORS.childWindowNotFoundError) || this;
}
return ChildWindowNotFoundError;
}(TestRunErrorBase));
var ChildWindowIsNotLoadedError = /** @class */ (function (_super) {
__extends(ChildWindowIsNotLoadedError, _super);
function ChildWindowIsNotLoadedError() {
return _super.call(this, TEST_RUN_ERRORS.childWindowIsNotLoadedError) || this;
}
return ChildWindowIsNotLoadedError;
}(TestRunErrorBase));
var CannotSwitchToWindowError = /** @class */ (function (_super) {
__extends(CannotSwitchToWindowError, _super);
function CannotSwitchToWindowError() {
return _super.call(this, TEST_RUN_ERRORS.cannotSwitchToWindowError) || this;
}
return CannotSwitchToWindowError;
}(TestRunErrorBase));
var CloseChildWindowError = /** @class */ (function (_super) {
__extends(CloseChildWindowError, _super);
function CloseChildWindowError() {
return _super.call(this, TEST_RUN_ERRORS.closeChildWindowError) || this;
}
return CloseChildWindowError;
}(TestRunErrorBase));
var CurrentIframeNotFoundError = /** @class */ (function (_super) {
__extends(CurrentIframeNotFoundError, _super);
function CurrentIframeNotFoundError() {
return _super.call(this, TEST_RUN_ERRORS.currentIframeNotFoundError) || this;
}
return CurrentIframeNotFoundError;
}(TestRunErrorBase));
var CurrentIframeIsInvisibleError = /** @class */ (function (_super) {
__extends(CurrentIframeIsInvisibleError, _super);
function CurrentIframeIsInvisibleError() {
return _super.call(this, TEST_RUN_ERRORS.currentIframeIsInvisibleError) || this;
}
return CurrentIframeIsInvisibleError;
}(TestRunErrorBase));
// Native dialog errors
var NativeDialogNotHandledError = /** @class */ (function (_super) {
__extends(NativeDialogNotHandledError, _super);
function NativeDialogNotHandledError(dialogType, url) {
var _this = _super.call(this, TEST_RUN_ERRORS.nativeDialogNotHandledError) || this;
_this.dialogType = dialogType;
_this.pageUrl = url;
return _this;
}
return NativeDialogNotHandledError;
}(TestRunErrorBase));
var UncaughtErrorInNativeDialogHandler = /** @class */ (function (_super) {
__extends(UncaughtErrorInNativeDialogHandler, _super);
function UncaughtErrorInNativeDialogHandler(dialogType, errMsg, url) {
var _this = _super.call(this, TEST_RUN_ERRORS.uncaughtErrorInNativeDialogHandler) || this;
_this.dialogType = dialogType;
_this.errMsg = errMsg;
_this.pageUrl = url;
return _this;
}
return UncaughtErrorInNativeDialogHandler;
}(TestRunErrorBase));
var SetNativeDialogHandlerCodeWrongTypeError = /** @class */ (function (_super) {
__extends(SetNativeDialogHandlerCodeWrongTypeError, _super);
function SetNativeDialogHandlerCodeWrongTypeError(actualType) {
var _this = _super.call(this, TEST_RUN_ERRORS.setNativeDialogHandlerCodeWrongTypeError) || this;
_this.actualType = actualType;
return _this;
}
return SetNativeDialogHandlerCodeWrongTypeError;
}(TestRunErrorBase));
var RequestHookUnhandledError = /** @class */ (function (_super) {
__extends(RequestHookUnhandledError, _super);
function RequestHookUnhandledError(err, hookClassName, methodName) {
var _this = _super.call(this, TEST_RUN_ERRORS.requestHookUnhandledError) || this;
_this.errMsg = String(err);
_this.hookClassName = hookClassName;
_this.methodName = methodName;
return _this;
}
return RequestHookUnhandledError;
}(TestRunErrorBase));
var RequestHookNotImplementedMethodError = /** @class */ (function (_super) {
__extends(RequestHookNotImplementedMethodError, _super);
function RequestHookNotImplementedMethodError(methodName, hookClassName) {
var _this = _super.call(this, TEST_RUN_ERRORS.requestHookNotImplementedError) || this;
_this.methodName = methodName;
_this.hookClassName = hookClassName;
return _this;
}
return RequestHookNotImplementedMethodError;
}(TestRunErrorBase));
var ChildWindowClosedBeforeSwitchingError = /** @class */ (function (_super) {
__extends(ChildWindowClosedBeforeSwitchingError, _super);
function ChildWindowClosedBeforeSwitchingError() {
return _super.call(this, TEST_RUN_ERRORS.childWindowClosedBeforeSwitchingError) || this;
}
return ChildWindowClosedBeforeSwitchingError;
}(TestRunErrorBase));
// -------------------------------------------------------------
// WARNING: this file is used by both the client and the server.
// Do not use any browser or node-specific API!
// -------------------------------------------------------------
var BrowserConsoleMessages = /** @class */ (function () {
function BrowserConsoleMessages(data) {
this.concat(data);
}
BrowserConsoleMessages.prototype.ensureMessageContainer = function (windowId) {
if (this[windowId])
return;
this[windowId] = {
log: [],
info: [],
warn: [],
error: []
};
};
BrowserConsoleMessages.prototype.concat = function (consoleMessages) {
var _this = this;
if (!consoleMessages)
return this;
Object.keys(consoleMessages).forEach(function (windowId) {
_this.ensureMessageContainer(windowId);
_this[windowId].log = _this[windowId].log.concat(consoleMessages[windowId].log);
_this[windowId].info = _this[windowId].info.concat(consoleMessages[windowId].info);
_this[windowId].warn = _this[windowId].warn.concat(consoleMessages[windowId].warn);
_this[windowId].error = _this[windowId].error.concat(consoleMessages[windowId].error);
});
return this;
};
BrowserConsoleMessages.prototype.addMessage = function (type, msg, windowId) {
this.ensureMessageContainer(windowId);
this[windowId][type].push(msg);
};
BrowserConsoleMessages.prototype.getCopy = function () {
var _this = this;
var copy = {};
Object.keys(this).forEach(function (windowId) {
copy[windowId] = {
log: _this[windowId].log.slice(),
info: _this[windowId].info.slice(),
warn: _this[windowId].warn.slice(),
error: _this[windowId].error.slice()
};
});
return copy;
};
return BrowserConsoleMessages;
}());
// ----------------------------------------------------------