import { Locator } from './by'; import { Element } from './element'; import { WindowRectangle } from './window'; type Serializable = number | string | boolean | null | undefined | bigint | JSONArray | JSONObject; type JSONArray = Serializable[]; interface JSONObject { [key: string]: Serializable; } export type SerializableOrElement = Serializable | Element | Element[]; export type MobileContextType = 'native' | 'web'; type MobileOs = 'android' | 'ios'; type MobileDeviceType = 'tablet' | 'phone'; export type MobilePlatformType = MobileOs | `${MobileOs}_${MobileDeviceType}` | 'web'; /** * parameters passed to Driver.waitFor method */ export interface WaitForOptions { /** * message thrown when wait timesout */ message?: string; /** * timeout in msec */ timeout?: number; /** * polling interval in msec */ interval?: number; } /** * Driver interface wraps a driver created inside a test */ export interface Driver { /** * Configuration parameters of the driver */ config: DriverConfig; /** * Execute script with given parameters * @param script String with a JavaScript to execute * @param args parameters that should be passed to the script */ executeScript(script: string | ((...args: any[]) => T), ...args: SerializableOrElement[]): Promise; /** * Wait for the truthy value of the condition passed as a parameter * @param condition condition or function to wait for * @param options waiting options like timeout, polling interval and error message * @param args optional parameters to be passed to the condition */ waitFor(condition: Promise | ((...args: SerializableOrElement[]) => T | Promise), options?: WaitForOptions, ...args: SerializableOrElement[]): Promise; /** * Find an element with a given locator directly inside the driver root. * If nothing found - throw an error * @param locator locator object (for web - css selector) */ findElement(locator: Locator): Promise; /** * Find all elements with a given locator directly inside the driver root. * If nothing found - throw an error * @param locator locator object (for web - css selector) */ findElements(locator: Locator): Promise; /** * Retrieves the URL. * * @returns A Promise that resolves to the URL. */ getUrl(): Promise; /** * Frames (IFrames & Frames) APIs * Enters the (i)frame specified by the given element * @param element - frame element to enter into */ enterFrame(element: Element): Promise; /** * Frames (IFrames & Frames) APIs * Exits focus from a(n) (i)frame to the immediate parent frame * @remarks * If already at the top-level frame, this is a no-op */ exitToParentFrame(): Promise; /** * Frames (IFrames & Frames) APIs * Exits focus from a(n) (i)frame to the page's default content * @remarks * If already at the top-level frame, this is a no-op */ exitFrame(): Promise; /** * Navigates backward in the current top-level browsing context */ back(): Promise; /** * Navigates forward in the current top-level browsing context */ forward(): Promise; /** * Retrieves the window handle of the current window. * * @returns A promise that resolves to the window handle as a string */ getWindowHandle(): Promise; /** * Retrieves the handles of all currently opened windows. * * @returns A promise that resolves to a set of window handles */ getWindowHandles(): Promise>; /** * Switch to the window matching the handle passed as a parameter * * @param windowHandle - The handle of the target window * @returns A promise that resolves when the driver has successfully switched to the target window */ switchTo(windowHandle: string): Promise; /** * Retrieves the current window's rectangle. * * @returns A promise that resolves to a {@link WindowRectangle} object representing the current window's rectangle */ getRect(): Promise; /** * Sets the current window's rectangle to the specified dimensions and position. * * @param rect - A {@link WindowRectangle} object representing the new window rectangle * @returns A promise that resolves when the window's rectangle has been successfully updated */ setRect(rect: WindowRectangle): Promise; /** * Closes the current window. * * @returns A promise that resolves when the window has been successfully closed. */ close(): Promise; /** * Sends a key to press, such as ArrowLeft * @param key String for the key to execute * Supported characters: https://w3c.github.io/webdriver/#keyboard-actions * @param options An optional text to write after the key pressed */ press(key: string, options?: { text: string; }): Promise; /** * mobile only: set driver context to NATIVE_APP, this happens when a page object is for native mobile component */ setPageContextToNative(): Promise; /** * mobile only: set driver context to the target WebView page, if view is different from current * * @param title web view title to switch to */ setPageContextToWebView(title?: string): Promise; /** * mobile only: set driver context to mobile web or native * * @param contextType platform to switch to, can be web or native * @param bridgeAppTitle webview page title */ setPageContext(contextType: MobileContextType, bridgeAppTitle?: string): Promise; /** * mobile only: check if current context is native * * @return boolean true if current context is native */ isNativeContext(): Promise; /** * mobile only: get current context, wraps AppiumDriver.getContext * * @return string with current context */ getPageContext(): Promise; } /** * DriverConfig should be passed to Driver during its construction * to ensure that all necessary configurable parameters are in fact configured */ export interface DriverConfig { /** * poll timeout in msec * used for all polling wait actions */ explicitTimeout?: number; /** * polling interval in msec * used for all polling wait actions as time between invocations of the wrapped action */ pollingInterval?: number; /** * implicit timeout in msec * used when we search for an element (Driver.findElement, Element.findElement) */ implicitTimeout?: number; /** * mobile only: bridge application title */ bridgeAppTitle?: string; /** * mobile only: platform type (one of ios, android and tablets). affects behavior of some methods */ platformType?: MobilePlatformType; } export {}; //# sourceMappingURL=driver.d.ts.map