@appium/base-driver
Version:
Base driver class for Appium drivers
346 lines • 13.9 kB
TypeScript
import { StatusCodes as HTTPStatusCodes } from 'http-status-codes';
import type { ErrorBiDiCommandResponse, Class } from '@appium/types';
declare class BaseError extends Error {
cause: Error | undefined;
message: string;
name: string;
stack: string | undefined;
constructor(message?: string, cause?: Error);
private _formatStack;
}
export declare class ProtocolError extends BaseError {
jsonwpCode: number;
error: string;
w3cStatus: number;
protected _stacktrace: string | undefined;
constructor(msg: string, jsonwpCode: number, w3cStatus: number, w3cErrorSignature: string, cause?: Error);
get stacktrace(): string | undefined;
set stacktrace(value: string | undefined);
/**
* Get the Bidi protocol version of an error
* @param id - the id used in the request for which this error forms the response
* @see https://w3c.github.io/webdriver-bidi/#protocol-definition
* @returns The object conforming to the shape of a BiDi error response
*/
bidiErrObject(id: string | number): ErrorBiDiCommandResponse;
}
export declare class NoSuchDriverError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class NoSuchElementError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
/**
* W3C WebDriver "no such shadow root" error. Issued when a command
* targets an element's shadow root that does not exist (or has been
* detached). Previously this was mis-classified as UnknownError — see
* https://github.com/appium/appium/issues/22209.
*/
export declare class NoSuchShadowRootError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static error(): string;
static w3cStatus(): HTTPStatusCodes;
}
export declare class NoSuchFrameError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static error(): string;
static w3cStatus(): HTTPStatusCodes;
}
export declare class UnknownCommandError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class StaleElementReferenceError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class ElementNotVisibleError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class InvalidElementStateError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class UnknownError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class UnknownMethodError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class UnsupportedOperationError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class ElementIsNotSelectableError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static error(): string;
static w3cStatus(): HTTPStatusCodes;
}
export declare class ElementClickInterceptedError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static error(): string;
static w3cStatus(): HTTPStatusCodes;
}
export declare class ElementNotInteractableError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static error(): string;
static w3cStatus(): HTTPStatusCodes;
}
export declare class InsecureCertificateError extends ProtocolError {
constructor(message?: string, cause?: Error);
static error(): string;
static w3cStatus(): HTTPStatusCodes;
}
export declare class JavaScriptError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class XPathLookupError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class TimeoutError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class NoSuchWindowError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static error(): string;
static w3cStatus(): HTTPStatusCodes;
}
export declare class InvalidArgumentError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static error(): string;
static w3cStatus(): HTTPStatusCodes;
}
export declare class InvalidCookieDomainError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static error(): string;
static w3cStatus(): HTTPStatusCodes;
}
export declare class NoSuchCookieError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class UnableToSetCookieError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class UnexpectedAlertOpenError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class NoAlertOpenError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class NoSuchAlertError extends NoAlertOpenError {
}
export declare class ScriptTimeoutError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class InvalidElementCoordinatesError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class InvalidCoordinatesError extends InvalidElementCoordinatesError {
}
export declare class IMENotAvailableError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class IMEEngineActivationFailedError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class InvalidSelectorError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class SessionNotCreatedError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class MoveTargetOutOfBoundsError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class NoSuchContextError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
}
export declare class InvalidContextError extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
}
export declare class NotYetImplementedError extends UnknownMethodError {
constructor(message?: string, cause?: Error);
}
export declare class NotImplementedError extends UnknownMethodError {
constructor(message?: string, cause?: Error);
}
export declare class UnableToCaptureScreen extends ProtocolError {
constructor(message?: string, cause?: Error);
static code(): number;
static w3cStatus(): HTTPStatusCodes;
static error(): string;
}
export declare class BadParametersError extends InvalidArgumentError {
constructor(paramReqs: ParameterRequirements, paramNames: string[]);
}
/**
* ProxyRequestError is a custom error and will be thrown up on unsuccessful proxy request and
* will contain information about the proxy failure.
* In case of ProxyRequestError should fetch the actual error by calling `getActualError()`
* for proxy failure to generate the client response.
*/
export declare class ProxyRequestError extends BaseError {
private readonly _w3cError?;
private readonly _w3cErrorStatus?;
private readonly _jwpError?;
constructor(message: string, httpResponseData: any, httpStatus?: number, cause?: Error);
private static _parseHttpResponse;
getActualError(): ProtocolError;
}
export declare const errors: {
readonly NotYetImplementedError: typeof NotYetImplementedError;
readonly NotImplementedError: typeof NotImplementedError;
readonly InvalidArgumentError: typeof InvalidArgumentError;
readonly NoSuchDriverError: typeof NoSuchDriverError;
readonly NoSuchElementError: typeof NoSuchElementError;
readonly UnknownCommandError: typeof UnknownCommandError;
readonly StaleElementReferenceError: typeof StaleElementReferenceError;
readonly ElementNotVisibleError: typeof ElementNotVisibleError;
readonly InvalidElementStateError: typeof InvalidElementStateError;
readonly UnknownError: typeof UnknownError;
readonly ElementIsNotSelectableError: typeof ElementIsNotSelectableError;
readonly ElementClickInterceptedError: typeof ElementClickInterceptedError;
readonly ElementNotInteractableError: typeof ElementNotInteractableError;
readonly InsecureCertificateError: typeof InsecureCertificateError;
readonly JavaScriptError: typeof JavaScriptError;
readonly XPathLookupError: typeof XPathLookupError;
readonly TimeoutError: typeof TimeoutError;
readonly NoSuchWindowError: typeof NoSuchWindowError;
readonly NoSuchCookieError: typeof NoSuchCookieError;
readonly InvalidCookieDomainError: typeof InvalidCookieDomainError;
readonly InvalidCoordinatesError: typeof InvalidCoordinatesError;
readonly UnableToSetCookieError: typeof UnableToSetCookieError;
readonly UnexpectedAlertOpenError: typeof UnexpectedAlertOpenError;
readonly NoAlertOpenError: typeof NoAlertOpenError;
readonly ScriptTimeoutError: typeof ScriptTimeoutError;
readonly InvalidElementCoordinatesError: typeof InvalidElementCoordinatesError;
readonly IMENotAvailableError: typeof IMENotAvailableError;
readonly IMEEngineActivationFailedError: typeof IMEEngineActivationFailedError;
readonly InvalidSelectorError: typeof InvalidSelectorError;
readonly SessionNotCreatedError: typeof SessionNotCreatedError;
readonly MoveTargetOutOfBoundsError: typeof MoveTargetOutOfBoundsError;
readonly NoSuchAlertError: typeof NoSuchAlertError;
readonly NoSuchContextError: typeof NoSuchContextError;
readonly InvalidContextError: typeof InvalidContextError;
readonly NoSuchFrameError: typeof NoSuchFrameError;
readonly NoSuchShadowRootError: typeof NoSuchShadowRootError;
readonly UnableToCaptureScreen: typeof UnableToCaptureScreen;
readonly UnknownMethodError: typeof UnknownMethodError;
readonly UnsupportedOperationError: typeof UnsupportedOperationError;
readonly ProxyRequestError: typeof ProxyRequestError;
};
interface W3CError {
error: string;
message?: string;
stacktrace?: string;
}
interface ParameterRequirements {
required: string[] | string;
optional?: string[] | string;
}
/**
* Type guard to check if an Error is of a specific type
*/
export declare function isErrorType<T>(err: any, type: Class<T>): err is T;
/**
* Retrieve an error derived from MJSONWP status
* @param code JSONWP status code
* @param value The error message, or an object with a `message` property
* @return The error that is associated with provided JSONWP status code
*/
export declare function errorFromMJSONWPStatusCode(code: number, value?: string | {
message: string;
}): ProtocolError;
/**
* Retrieve an error derived from W3C JSON Code
* @param signature W3C error string (see https://www.w3.org/TR/webdriver/#handling-errors `JSON Error Code` column)
* @param message the error message
* @param stacktrace an optional error stacktrace
* @return The error that is associated with the W3C error string
*/
export declare function errorFromW3CJsonCode(signature: string, message: string, stacktrace?: string): ProtocolError;
/**
* Convert an Appium error to proper W3C HTTP response
*
* @param err The error that needs to be translated
*/
export declare function getResponseForW3CError(err: any): [number, {
value: W3CError;
}];
export {};
//# sourceMappingURL=errors.d.ts.map