UNPKG

webdriver

Version:

A Node.js bindings implementation for the W3C WebDriver and WebDriver Bidi protocols

115 lines • 6.39 kB
import type { EventEmitter } from 'node:events'; import type { CommandEndpoint } from '@wdio/protocols'; import type { Capabilities, Options } from '@wdio/types'; import type { ClientOptions } from 'ws'; import { BidiHandler } from './bidi/handler.js'; import type { Client, SessionRequestError, SessionFlags, RemoteConfig, CommandRuntimeOptions } from './types.js'; /** * start browser session with WebDriver protocol */ export declare function startWebDriverSession(params: RemoteConfig): Promise<{ sessionId: string; capabilities: WebdriverIO.Capabilities; }>; /** * what the user can do when the WebDriver Bidi server of an Appium browser session can not run * browser commands: only Chrome on Android can get WebDriver Bidi through the browser driver * * @param capabilities capabilities of the session * @param requestedCapabilities capabilities that the user requested */ export declare function getAppiumBidiAdvice(capabilities: WebdriverIO.Capabilities, requestedCapabilities: Capabilities.RequestedStandaloneCapabilities): "" | "Appium answers WebDriver Bidi itself, because \"appium:chromedriverForwardBiDi\" is false. " | "For WebDriver Bidi with Chrome on Android, use Appium 3.9.0 or later with the UiAutomator2 driver 8.7.3 or later. "; /** * Validates the given WebdriverIO capabilities. * * @param {WebdriverIO.Capabilities} capabilities - The capabilities to validate. * @throws {Error} If the capabilities contain incognito mode. */ export declare function validateCapabilities(capabilities: WebdriverIO.Capabilities): void; /** * check if WebDriver requests was successful * @param {number} statusCode status code of request * @param {Object} body body payload of response * @return {Boolean} true if request was successful */ export declare function isSuccessfulResponse(statusCode?: number, body?: unknown): boolean; /** * creates the base prototype for the webdriver monad */ export declare function getPrototype({ isChromium, isFirefox, isMobile, isSauce, isSeleniumStandalone }: Partial<SessionFlags>): Record<string, PropertyDescriptor>; /** * return all supported flags and return them in a format so we can attach them * to the instance protocol * @param {Object} options driver instance or option object containing these flags * @return {Object} prototype object */ export declare function getEnvironmentVars({ isMobile, isIOS, isAndroid, isFirefox, isSauce, isSeleniumStandalone, isChromium, isWindowsApp, isMacApp }: Partial<SessionFlags>): PropertyDescriptorMap; /** * Decorate the client's options object with host updates based on the presence of * directConnect capabilities in the new session response. Note that this * mutates the object. * @param {Client} params post-new-session client */ export declare function setupDirectConnect(client: Client): void; /** * get human-readable message from response error * @param {Error} err response error * @param params */ export declare const getSessionError: (err: SessionRequestError, params?: Partial<Options.WebDriver>) => string; /** * Build WebSocket client options for a BiDi connection. * * Always enables redirect following so Grid proxies that 301/302 from * `ws://` to `wss://` (or another node) can be used. Custom headers are * forwarded as-is, including to redirect targets. Grid redirects are * expected to stay within trusted infrastructure; a misconfigured * cross-host redirect would also forward credentials. */ export declare function getBidiRequestOptions(strictSSL?: boolean, headers?: Record<string, string>): ClientOptions; /** * Enhance the monad with WebDriver Bidi primitives if a connection can be established successfully * @param socketUrl url to bidi interface * @param strictSSL * @param userHeaders * @param responseTimeout timeout for a Bidi command to receive a response from the browser * @param connectTimeout timeout for the browser to accept the Bidi connection * @returns prototype with interface for bidi primitives */ export declare function initiateBidi(socketUrl: string, strictSSL?: boolean, userHeaders?: Record<string, string>, responseTimeout?: number, connectTimeout?: number): PropertyDescriptorMap; /** * Appium (since 2.15) gives its own WebDriver Bidi url to each session that asks for it, * unless it forwards the socket to the browser driver. That server has no * `browsingContext` or `script` module, so a browser session must use WebDriver Classic. * * @param handler the connected handler of an Appium browser session * @param timeout how long to wait for the answer (`bidiConnectTimeout`): a server that never * answers must not hold the session start for `bidiResponseTimeout`; a shorter * `bidiResponseTimeout` ends the check first * @param advice what the user can do, see `getAppiumBidiAdvice` * @return `false` when the connection was discarded */ export declare function discardBidiWithoutBrowsingContext(handler: BidiHandler, timeout: number, advice?: string): Promise<boolean>; export declare function parseBidiMessage(this: EventEmitter, data: ArrayBuffer): void; /** * Masks the `text` parameter in a WebDriver command if masking is enabled in the options. * * - If `options.mask` is not set or the command does not have a `text` parameter, returns the original body and args. * - If masking is enabled and a `text` parameter is present and non-empty, replaces its value with the mask in both the body and args. * * @param {CommandEndpoint} commandInfo - The command endpoint metadata, including parameters and variables. * @param {CommandRuntimeOptions} options - Runtime options for the command, including the `mask` flag. * @param {Record<string, unknown>} body - The request body object to potentially mask. * @param {unknown[]} args - The arguments array to potentially mask. * @returns {{ * maskedBody: Record<string, unknown>, * maskedArgs: unknown[], * isMasked: boolean * }} An object containing the (possibly) masked body and args, and a flag indicating if masking was applied. */ export declare function mask(commandInfo: CommandEndpoint, options: CommandRuntimeOptions, body: Record<string, unknown>, args: unknown[]): { maskedBody: Record<string, unknown>; maskedArgs: unknown[]; isMasked: boolean; }; //# sourceMappingURL=utils.d.ts.map