import events from 'node:events'; import { WebDriverProxy, PROTOCOLS } from '@appium/base-driver'; import type { HTTPMethod, HTTPBody } from '@appium/types'; import type { ADB } from 'appium-adb'; import type { Request, Response } from 'express'; import { SubProcess, exec } from 'teen_process'; import { type SessionCapabilities } from './commands/session.js'; import { CHROMEDRIVER_EVENTS, CHROMEDRIVER_STATES } from './constants.js'; import { ChromedriverStorageClient } from './storage-client/storage-client.js'; import type { ChromedriverOpts } from './types.js'; 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 { 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: WebDriverProxy; 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 | 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; /** * 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; /** * Stops the current Chromedriver session and underlying subprocess. * * @param emitStates - Whether to emit stopping/stopped state transitions. */ stop(emitStates?: boolean): Promise; /** * 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; /** * 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; /** * Checks whether the active webview connection is currently responsive. * * @returns `true` if `/url` command succeeds, otherwise `false`. */ hasWorkingWebview(): Promise; private prepareCapabilitiesForSessionStart; private attachChromedriverProcessListeners; private launchChromedriverProcess; private formatChromeVersionMismatchHint; private handleChromedriverStartFailure; } export {}; //# sourceMappingURL=chromedriver.d.ts.map