UNPKG

@openfin/automation-helpers

Version:

Helper methods for automation testing in the OpenFin ecosystem

107 lines (106 loc) 4.17 kB
import type { Client } from "webdriver"; import type { IRect } from "../models/IRect"; import type { IWebDriverElement } from "../models/IWebDriverElement"; import type { LocatorTypes } from "../models/locatorTypes"; import { BaseWebDriverElement } from "./baseWebDriverElement"; /** * Webdriver element for the Node environment. */ export declare class NodeWebDriverElement extends BaseWebDriverElement<Client> implements IWebDriverElement { /** * The reference for the element. */ private readonly _elementId; /** * Create a new instance of NodeWebDriverElement. * @param client The client to use for chromedriver calls. * @param locator The locator to use when finding the element. * @param locatorValue The value to use with the locator. * @param locatorIndex The index to use with the locator. * @param elementId The reference to the element. */ constructor(client: Client, locator: LocatorTypes, locatorValue: string, locatorIndex: number, elementId: string); /** * Get an element id from an element reference. * @param elementReference The element reference to get the element id from. * @returns The element id. */ static elementIdFromReference(elementReference: Record<"element-6066-11e4-a52e-4f735466cecf", string | undefined>): string | undefined; /** * Find an element. * @param locator The locator to use when finding the element. * @param locatorValue The value to use with the locator. * @returns The element if found. * @see https://w3c.github.io/webdriver/#dfn-find-element */ findElement(locator: LocatorTypes, locatorValue: string): Promise<IWebDriverElement | undefined>; /** * Find elements. * @param locator The locator to use when finding the elements. * @param locatorValue The value to use with the locator. * @returns The elements if found. * @see https://w3c.github.io/webdriver/#dfn-find-elements */ findElements(locator: LocatorTypes, locatorValue: string): Promise<IWebDriverElement[]>; /** * Send a click to an item. * @returns Nothing. * @see https://w3c.github.io/webdriver/#dfn-element-click */ click(): Promise<void>; /** * Send keys to an element. * @param keys The keys to send to the element. * @returns Nothing. * @see https://w3c.github.io/webdriver/#dfn-element-send-keys */ sendKeys(keys: string): Promise<void>; /** * Get the text for an element. * @returns The text. * @see https://w3c.github.io/webdriver/#dfn-get-element-text */ getText(): Promise<string>; /** * Is the element enabled. * @returns True if the element is enabled. * @see https://w3c.github.io/webdriver/#dfn-is-element-enabled */ isEnabled(): Promise<boolean>; /** * Is the element displayed. * @returns True if the element is displayed. * @see https://w3c.github.io/webdriver/#element-displayedness */ isDisplayed(): Promise<boolean>; /** * Is the element selected. * @returns True if the element is selected. * @see https://w3c.github.io/webdriver/#dfn-is-element-selected */ isSelected(): Promise<boolean>; /** * Take a screenshot of the element. * @returns Returns a base64 encoded png. * @see https://w3c.github.io/webdriver/#dfn-take-element-screenshot */ screenshot(): Promise<string>; /** * Execute JavaScript in the window. * @param script The script to execute. * @param args Arguments to pass to the async script. * @returns The response from the execute. * @see https://w3c.github.io/webdriver/#dfn-execute-async-script */ executeAsyncScript<T>(script: string, args?: (string | object | number | boolean | undefined)[]): Promise<T>; /** * Get the element rectangle. * @returns The size and position of the element. */ rect(): Promise<IRect>; /** * Get the native element. * @returns The native element for the driver. */ nativeElement(): Record<"element-6066-11e4-a52e-4f735466cecf", string>; }