UNPKG

appium-android-driver

Version:

Android UiAutomator and Chrome support for Appium

105 lines 5.21 kB
import { Chromedriver } from 'appium-chromedriver'; import type { AndroidDriver, AndroidDriverOpts } from '../../driver'; import type { GetWebviewsOpts, WebviewsMapping } from '../types'; export declare const CHROME_BROWSER_PACKAGE_ACTIVITY: { readonly chrome: { readonly pkg: "com.android.chrome"; readonly activity: "com.google.android.apps.chrome.Main"; }; readonly chromium: { readonly pkg: "org.chromium.chrome.shell"; readonly activity: ".ChromeShellActivity"; }; readonly chromebeta: { readonly pkg: "com.chrome.beta"; readonly activity: "com.google.android.apps.chrome.Main"; }; readonly browser: { readonly pkg: "com.android.browser"; readonly activity: "com.android.browser.BrowserActivity"; }; readonly 'chromium-browser': { readonly pkg: "org.chromium.chrome"; readonly activity: "com.google.android.apps.chrome.Main"; }; readonly 'chromium-webview': { readonly pkg: "org.chromium.webview_shell"; readonly activity: "org.chromium.webview_shell.WebViewBrowserActivity"; }; readonly default: { readonly pkg: "com.android.chrome"; readonly activity: "com.google.android.apps.chrome.Main"; }; }; export declare const CHROME_PACKAGE_NAME = "com.android.chrome"; export declare const KNOWN_CHROME_PACKAGE_NAMES: readonly ["com.android.chrome", "com.chrome.beta", "com.chrome.dev", "com.chrome.canary"]; export declare const NATIVE_WIN = "NATIVE_APP"; export declare const WEBVIEW_WIN = "WEBVIEW"; export declare const CHROMIUM_WIN = "CHROMIUM"; export declare const WEBVIEW_BASE = "WEBVIEW_"; export declare const DEVTOOLS_SOCKET_PATTERN: RegExp; /** * Gets the Chrome browser package and activity information for the specified browser name. * * @param browser - The browser name (e.g., 'chrome', 'chromium', 'chromebeta') * @returns The package and activity information for the browser, or the default Chrome configuration */ export declare function getChromePkg(browser: string): (typeof CHROME_BROWSER_PACKAGE_ACTIVITY)[keyof typeof CHROME_BROWSER_PACKAGE_ACTIVITY]; /** * Parses webview names from the webviews mapping for use in getContexts. * Filters out webviews that don't have pages if ensureWebviewsHavePages is enabled. * * @param webviewsMapping - Array of webview mapping objects * @param options - Options including ensureWebviewsHavePages and isChromeSession flags * @returns An array of webview context names */ export declare function parseWebviewNames(this: AndroidDriver, webviewsMapping: WebviewsMapping[], options?: GetWebviewsOpts & { isChromeSession?: boolean; }): string[]; /** * Get a list of available webviews mapping by introspecting processes with adb, * where webviews are listed. It's possible to pass in a 'deviceSocket' arg, which * limits the webview possibilities to the one running on the Chromium devtools * socket we're interested in (see note on webviewsFromProcs). We can also * direct this method to verify whether a particular webview process actually * has any pages (if a process exists but no pages are found, Chromedriver will * not actually be able to connect to it, so this serves as a guard for that * strange failure mode). The strategy for checking whether any pages are * active involves sending a request to the remote debug server on the device, * hence it is also possible to specify the port on the host machine which * should be used for this communication. * * @param opts - Options for webview discovery including device socket, port, and collection settings * @returns An array of webview mapping objects */ export declare function getWebViewsMapping(this: AndroidDriver, opts?: GetWebviewsOpts): Promise<WebviewsMapping[]>; /** * Sets up a new Chromedriver instance for the specified context. * * @param opts - Driver options with Chrome-specific settings * @param curDeviceId - The current device ID * @param context - Optional context name for webview sessions * @returns A configured Chromedriver instance */ export declare function setupNewChromedriver(this: AndroidDriver, opts: AndroidDriverOpts & Record<string, any>, curDeviceId: string, context?: string): Promise<Chromedriver>; /** * Sets up an existing Chromedriver instance, checking if it's still working. * If not, restarts the session. * * @param chromedriver - The existing Chromedriver instance * @param context - The context name associated with this Chromedriver * @returns The Chromedriver instance (possibly restarted) */ export declare function setupExistingChromedriver<T extends Chromedriver>(this: AndroidDriver, chromedriver: T, context: string): Promise<T>; /** * Determines if the Chrome welcome dialog should be dismissed based on Chrome options. * * @returns True if the '--no-first-run' argument is present in chromeOptions */ export declare function shouldDismissChromeWelcome(this: AndroidDriver): boolean; /** * Dismisses the Chrome welcome dialog if it appears. * Handles both the terms acceptance and sign-in dialog. */ export declare function dismissChromeWelcome(this: AndroidDriver): Promise<void>; //# sourceMappingURL=helpers.d.ts.map