UNPKG

@openfin/automation-helpers

Version:

Helper methods for automation testing in the OpenFin ecosystem

101 lines (100 loc) 3.9 kB
import { type ThenableWebDriver, type WebElement } from "selenium-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 Selenium environment. */ export declare class SeleniumWebDriverElement extends BaseWebDriverElement<ThenableWebDriver> implements IWebDriverElement { /** * The reference for the element. */ private readonly _webElement; /** * Create a new instance of SeleniumWebDriverElement. * @param webDriver The web driver 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 webElement The reference to the element. */ constructor(webDriver: ThenableWebDriver, locator: LocatorTypes, locatorValue: string, locatorIndex: number, webElement: WebElement); /** * 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(): WebElement; }