UNPKG

appium-android-driver

Version:

Android UiAutomator and Chrome support for Appium

129 lines 5.52 kB
import type { StringRecord } from '@appium/types'; import type { AndroidDriver } from '../../driver'; import type { WebviewsMapping } from '../types'; /** * Gets the current context name. Returns the default context if no context is explicitly set. * * @returns The current context name */ export declare function getCurrentContext(this: AndroidDriver): Promise<string>; /** * Gets a list of all available contexts (native and webviews). * * @returns An array of context names */ export declare function getContexts(this: AndroidDriver): Promise<string[]>; /** * Sets the current context to the specified context name. * * @param name - The context name to switch to. If not provided or null, defaults to the native context. * If "WEBVIEW", uses the default webview name. * @throws {errors.NoSuchContextError} If the specified context does not exist */ export declare function setContext(this: AndroidDriver, name?: string | null): Promise<void>; /** * Gets a detailed list of all available webview contexts with their mapping information. * * @param waitForWebviewMs - Optional timeout in milliseconds to wait for webviews to appear * @returns An array of webview mapping objects containing detailed information about each webview */ export declare function mobileGetContexts(this: AndroidDriver, waitForWebviewMs?: number): Promise<WebviewsMapping[]>; /** * Assigns and returns a list of available contexts based on the webviews mapping. * * @param webviewsMapping - Array of webview mapping objects * @returns An array of context names (always includes NATIVE_APP as the first element) */ export declare function assignContexts(this: AndroidDriver, webviewsMapping: WebviewsMapping[]): string[]; /** * Switches to the specified context. Handles Chromedriver proxy setup/teardown as needed. * * @param name - The context name to switch to * @param webviewsMapping - Array of webview mapping objects * @throws {Error} If the context cannot be handled */ export declare function switchContext(this: AndroidDriver, name: string, webviewsMapping: WebviewsMapping[]): Promise<void>; /** * Returns the default native context name. * * @returns The native context name ("NATIVE_APP") */ export declare function defaultContextName(this: AndroidDriver): string; /** * Returns the default webview name based on the app package or auto webview name option. * * @returns The default webview name */ export declare function defaultWebviewName(this: AndroidDriver): string; /** * Checks if the current context is a web context (not native). * * @returns True if the current context is a webview, false otherwise */ export declare function isWebContext(this: AndroidDriver): boolean; /** * Gets the current window handle. Returns a default handle for native contexts. * * @returns The current window handle */ export declare function getWindowHandle(this: AndroidDriver): Promise<string>; /** * Gets all available window handles. Returns a default handle for native contexts. * * @returns An array of window handles */ export declare function getWindowHandles(this: AndroidDriver): Promise<string[]>; /** * Sets the current window to the specified handle. Does nothing for native contexts. * * @param handle - The window handle to switch to */ export declare function setWindow(this: AndroidDriver, handle: string): Promise<void>; /** * Turns on proxying to an existing Chromedriver session or creates a new one. * * @param context - The context name to connect to * @param webviewsMapping - Array of webview mapping objects */ export declare function startChromedriverProxy(this: AndroidDriver, context: string, webviewsMapping: WebviewsMapping[]): Promise<void>; /** * Stops proxying to any Chromedriver and clears the proxy state. */ export declare function suspendChromedriverProxy(this: AndroidDriver): void; /** * Handles an out-of-band Chromedriver stop event. * If the stopped context is the current context, triggers an unexpected shutdown. * Otherwise, logs a warning and removes the context from the session. * * @param context - The context name where Chromedriver stopped */ export declare function onChromedriverStop(this: AndroidDriver, context: string): Promise<void>; /** * Intentionally stops all the chromedrivers currently active and ignores their exit events. */ export declare function stopChromedriverProxies(this: AndroidDriver): Promise<void>; /** * Checks if a context name represents a Chromedriver-backed webview context. * * @param viewName - The context name to check * @returns True if the context is a Chromedriver context, false otherwise */ export declare function isChromedriverContext(this: AndroidDriver, viewName: string): boolean; /** * Notifies BiDi clients about a context change event. * See https://github.com/appium/appium/issues/20741 */ export declare function notifyBiDiContextChange(this: AndroidDriver): Promise<void>; /** * Gets the ChromeDriver session capabilities for the current webview context. * * @returns The ChromeDriver session capabilities * @throws {errors.InvalidContextError} If not in a webview context * @throws {Error} If no ChromeDriver session capabilities are found */ export declare function mobileGetChromeCapabilities(this: AndroidDriver): Promise<StringRecord>; /** * Starts a Chrome-based browser session and sets up the Chromedriver proxy. */ export declare function startChromeSession(this: AndroidDriver): Promise<void>; //# sourceMappingURL=exports.d.ts.map