@openfin/automation-helpers
Version:
Helper methods for automation testing in the OpenFin ecosystem
131 lines (130 loc) • 4.44 kB
TypeScript
import type * as CSS from "csstype";
import type { IWebDriverElement } from "../models/IWebDriverElement";
import type { LocatorTypes } from "../models/locatorTypes";
/**
* BaseWebDriverElement shared methods.
*/
export declare abstract class BaseWebDriverElement<T> implements Partial<IWebDriverElement> {
/**
* The selenium web driver to make the chromedriver calls with.
*/
protected readonly _client: T;
/**
* The locator to use when finding the element.
*/
protected readonly _locator: LocatorTypes;
/**
* The value to use with the locator.
*/
protected readonly _locatorValue: string;
/**
* The index to use with the locator.
*/
protected readonly _locatorIndex: number;
/**
* Create a new instance of BaseWebDriverElement.
* @param client 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.
*/
constructor(client: T, locator: LocatorTypes, locatorValue: string, locatorIndex: number);
/**
* 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.
* @param property The property to get.
* @returns The property.
*/
getProperty<U>(property: string): Promise<U>;
/**
* Set a property for an element.
* @param property The property to set.
* @param value The value to set.
* @returns Nothing.
*/
setProperty<U>(property: string, value: U): Promise<void>;
/**
* Remove a property from an element.
* @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>;
/**
* Set the keyboard focus to the element.
* @returns Nothing.
*/
focus(): Promise<void>;
/**
* 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<U>(method: string, params?: (string | object | number | boolean | undefined)[], awaitReturn?: boolean): Promise<U>;
/**
* Build code to lookup the locator.
* @returns The code for the locator.
*/
private buildLocatorLookup;
/**
* 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
*/
abstract executeAsyncScript<U>(script: string, args?: (string | object | number | boolean | undefined)[]): Promise<U>;
}