@openfin/automation-helpers
Version:
Helper methods for automation testing in the OpenFin ecosystem
163 lines (162 loc) • 5.37 kB
TypeScript
import type * as CSS from "csstype";
import type { IRect } from "./IRect";
import type { LocatorTypes } from "./locatorTypes";
/**
* Web driver element interface.
*/
export interface IWebDriverElement {
/**
* Find an element.
* @param locator The locator to use when finding the element.
* @param value The value to use with the locator.
* @returns The element if found.
* @see https://w3c.github.io/webdriver/#dfn-find-element
*/
findElement(locator: LocatorTypes, value: string): Promise<IWebDriverElement | undefined>;
/**
* Find elements.
* @param locator The locator to use when finding the elements.
* @param value The value to use with the locator.
* @returns The elements if found.
* @see https://w3c.github.io/webdriver/#dfn-find-elements
*/
findElements(locator: LocatorTypes, value: 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>;
/**
* Set the text for an element.
* @param text The text to set.
* @returns Nothing.
*/
setText(text: string): Promise<void>;
/**
* Get the HTML for an element.
* @returns The HTML.
*/
getHTML(): Promise<string>;
/**
* Set the HTML for an element.
* @param html The html to set.
* @returns Nothing.
*/
setHTML(html: string): Promise<void>;
/**
* Get an attribute for an element using executeAsyncScript.
* @param attribute The attribute to get.
* @returns The attribute.
*/
getAttribute(attribute: string): Promise<string>;
/**
* Set an attribute for an element using executeAsyncScript.
* @param attribute The attribute to set.
* @param value The value to set.
* @returns Nothing.
*/
setAttribute(attribute: string, value: string): Promise<void>;
/**
* Remove an attribute from an element using executeAsyncScript.
* @param attribute The attribute to remove.
* @returns Nothing.
*/
removeAttribute(attribute: string): Promise<void>;
/**
* Get a property for an element using executeAsyncScript.
* @param property The property to get.
* @returns The property.
*/
getProperty<T>(property: string): Promise<T>;
/**
* Set a property for an element using executeAsyncScript.
* @param property The property to set.
* @param value The value to set.
* @returns Nothing.
*/
setProperty<T>(property: string, value: T): Promise<void>;
/**
* Remove a property from an element using executeAsyncScript.
* @param property The property to remove.
* @returns Nothing.
*/
removeProperty(property: string): Promise<void>;
/**
* Get the style for the element.
* @returns The style.
*/
getStyle(): Promise<CSS.Properties>;
/**
* Set the style for the element.
* @param style The styles to set.
* @returns Nothing.
*/
setStyle(style: CSS.Properties): Promise<void>;
/**
* Remove the styles from the element.
* @param styles The styles to remove.
* @returns Nothing.
*/
removeStyle(styles: (keyof CSS.Properties)[]): Promise<void>;
/**
* 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>;
/**
* Set the keyboard focus to the element.
* @returns Nothing.
*/
focus(): Promise<void>;
/**
* 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>;
/**
* 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(): unknown;
/**
* Call the execute async script for the specified method on the object.
* @param method The method to call on the OpenFin object.
* @param params Parameters to call the object with.
* @param awaitReturn Await the return from the method.
* @returns The result from the call.
*/
callMethod<T>(method: string, params?: (string | object | number | boolean | undefined)[], awaitReturn?: boolean): Promise<T>;
}