appium-chromedriver
Version:
Node.js wrapper around chromedriver.
122 lines • 4.76 kB
TypeScript
import events from 'node:events';
import { JWProxy, PROTOCOLS } from '@appium/base-driver';
import { SubProcess, exec } from 'teen_process';
import { ChromedriverStorageClient } from './storage-client/storage-client';
import { CHROMEDRIVER_EVENTS, CHROMEDRIVER_STATES } from './constants';
import { type SessionCapabilities } from './commands/session';
import type { ADB } from 'appium-adb';
import type { HTTPMethod, HTTPBody } from '@appium/types';
import type { Request, Response } from 'express';
import type { ChromedriverOpts } from './types';
export type ChromedriverState = (typeof CHROMEDRIVER_STATES)[keyof typeof CHROMEDRIVER_STATES];
type ChromedriverEventMap = {
[CHROMEDRIVER_EVENTS.ERROR]: [Error];
[CHROMEDRIVER_EVENTS.CHANGED]: [{
state: ChromedriverState;
}];
};
export declare class Chromedriver extends events.EventEmitter<ChromedriverEventMap> {
static readonly EVENT_ERROR: "chromedriver_error";
static readonly EVENT_CHANGED: "stateChanged";
static readonly STATE_STOPPED: "stopped";
static readonly STATE_STARTING: "starting";
static readonly STATE_ONLINE: "online";
static readonly STATE_STOPPING: "stopping";
static readonly STATE_RESTARTING: "restarting";
readonly proxyPort: number;
readonly adb?: ADB;
readonly cmdArgs?: string[];
proc: SubProcess | null;
readonly useSystemExecutable: boolean;
chromedriver?: string;
readonly executableDir: string;
readonly mappingPath?: string;
bundleId?: string;
executableVerified: boolean;
state: string;
_execFunc: typeof exec;
jwproxy: JWProxy;
readonly isCustomExecutableDir: boolean;
readonly verbose?: boolean;
readonly logPath?: string;
readonly disableBuildCheck: boolean;
readonly storageClient: ChromedriverStorageClient | null;
readonly details?: ChromedriverOpts['details'];
capabilities: SessionCapabilities;
_desiredProtocol: keyof typeof PROTOCOLS | null;
_driverVersion: string | null;
_onlineStatus: Record<string, any> | null;
private readonly _log;
private readonly proxyHost;
private buildChromedriverArgs;
private getDriversMapping;
private getChromedrivers;
private updateDriversMapping;
private getCompatibleChromedriver;
private initChromedriverPath;
private getChromeVersion;
private syncProtocol;
private waitForOnline;
private getStatus;
private killAll;
private changeState;
private startSession;
constructor(args?: ChromedriverOpts);
get log(): any;
get driverVersion(): string | null;
/**
* Starts a new Chromedriver session with the given capabilities.
*
* @param caps - Capabilities passed to Chromedriver session creation.
* @param emitStartingState - Whether to emit the `starting` state transition.
* @returns Session capabilities returned by Chromedriver.
*/
start(caps: SessionCapabilities, emitStartingState?: boolean): Promise<SessionCapabilities>;
/**
* Gets active Chromedriver session id if the driver is online.
*
* @returns The session id or `null` when driver is not online.
*/
sessionId(): string | null;
/**
* Restarts current Chromedriver session with previously stored capabilities.
*
* @returns Session capabilities returned by the restarted session.
*/
restart(): Promise<SessionCapabilities>;
/**
* Stops the current Chromedriver session and underlying subprocess.
*
* @param emitStates - Whether to emit stopping/stopped state transitions.
*/
stop(emitStates?: boolean): Promise<void>;
/**
* Sends a direct command to Chromedriver through the JSONWP/W3C proxy.
*
* @param url - Chromedriver endpoint path.
* @param method - HTTP method used for the command.
* @param body - Optional request payload.
* @returns Command response payload.
*/
sendCommand(url: string, method: HTTPMethod, body?: HTTPBody): Promise<HTTPBody>;
/**
* Proxies an incoming Express request/response pair to Chromedriver.
*
* @param req - Incoming request object.
* @param res - Outgoing response object.
*/
proxyReq(req: Request, res: Response): Promise<void>;
/**
* Checks whether the active webview connection is currently responsive.
*
* @returns `true` if `/url` command succeeds, otherwise `false`.
*/
hasWorkingWebview(): Promise<boolean>;
private prepareCapabilitiesForSessionStart;
private attachChromedriverProcessListeners;
private launchChromedriverProcess;
private formatChromeVersionMismatchHint;
private handleChromedriverStartFailure;
}
export {};
//# sourceMappingURL=chromedriver.d.ts.map