@openfin/automation-helpers
Version:
Helper methods for automation testing in the OpenFin ecosystem
138 lines (137 loc) • 6.21 kB
TypeScript
import type { IWebDriverElement } from "./IWebDriverElement";
import type { IWebDriverWindow } from "./IWebDriverWindow";
import type { LocatorTypes } from "./locatorTypes";
import type { WebDriverAction } from "./webDriverAction";
import type { WindowLocatorTypes } from "./windowLocatorTypes";
import type { WindowLocatorIdentityStringValueTypes, WindowLocatorIdentityValueTypes, WindowLocatorValueTypes } from "./windowLocatorValueTypes";
/**
* Web driver interface.
*/
export interface IWebDriver {
/**
* Start a new session on the driver.
* @param devToolsPort The devtool port.
* @param chromeDriverPort The chromedriver port.
* @param logLevel The level of logging.
* @param screenshotFolder The folder for storing screen shots.
* @param openFinRVMPath The path to the OpenFin RVM.
* @param openFinEnv Additional OpenFin environment data.
* @param openFinEnv.workspaceVersion The version of workspace.
* @param openFinEnv.notificationsVersion The version of notifications.
* @returns Nothing.
* @see https://w3c.github.io/webdriver/#dfn-new-sessions
*/
startSession(devToolsPort: number, chromeDriverPort: number, logLevel: "debug" | "silent", screenshotFolder: string, openFinRVMPath: string, openFinEnv: {
workspaceVersion: string;
notificationsVersion: string;
}): Promise<void>;
/**
* End a session on the driver.
* @returns Nothing.
* @see https://w3c.github.io/webdriver/#dfn-delete-session
*/
endSession(): Promise<void>;
/**
* 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 title of the current window.
* @returns The window title.
* @see https://w3c.github.io/webdriver/#dfn-get-title
*/
getTitle(): Promise<string | undefined>;
/**
* Get the URL of the current window.
* @returns The window title.
* @see https://w3c.github.io/webdriver/#dfn-get-current-url
*/
getUrl(): Promise<string | undefined>;
/**
* Set the URL of the current window.
* @param url The url to navigate to.
* @returns Nothing.
* @see https://w3c.github.io/webdriver/#dfn-navigate-to
*/
setUrl(url: string): Promise<void>;
/**
* Get the details of all the connected windows.
* @returns The list of windows.
* @see https://w3c.github.io/webdriver/#dfn-get-window-handles
*/
getWindows(): Promise<IWebDriverWindow[]>;
/**
* Get the details of the current window.
* @returns The current window if available.
* @see https://w3c.github.io/webdriver/#dfn-get-window-handle
*/
getWindow(): Promise<IWebDriverWindow | undefined>;
/**
* Switch to a window by locator.
* @param locator The locator type.
* @param locatorValue The window locator value to use.
* @param activateNativeWindow Activate the native window as well, defaults to true.
* @returns True if the window was available.
* @see https://w3c.github.io/webdriver/#dfn-switch-to-window
*/
switchToWindow(locator: "title" | "url" | "handle" | "identityString", locatorValue: string | RegExp | (string | RegExp)[], activateNativeWindow?: boolean): Promise<boolean>;
/**
* Switch to a window by locator.
* @param locator The locator type.
* @param locatorValue The window locator value to use.
* @param activateNativeWindow Activate the native window as well, defaults to true.
* @returns True if the window was available.
* @see https://w3c.github.io/webdriver/#dfn-switch-to-window
*/
switchToWindow(locator: "identity", locatorValue: WindowLocatorIdentityValueTypes, activateNativeWindow?: boolean): Promise<boolean>;
/**
* Switch to a window by locator.
* @param locator The locator type.
* @param locatorValue The window locator value to use.
* @param activateNativeWindow Activate the native window as well, defaults to true.
* @returns True if the window was available.
* @see https://w3c.github.io/webdriver/#dfn-switch-to-window
*/
switchToWindow(locator: "identityString", locatorValue: WindowLocatorIdentityStringValueTypes, activateNativeWindow?: boolean): Promise<boolean>;
/**
* Switch to a window by locator.
* @param locator The locator type.
* @param locatorValue The window locator value to use.
* @param activateNativeWindow Activate the native window as well, defaults to true.
* @returns True if the window was available.
* @see https://w3c.github.io/webdriver/#dfn-switch-to-window
*/
switchToWindow(locator: WindowLocatorTypes, locatorValue: WindowLocatorValueTypes, activateNativeWindow?: boolean): Promise<boolean>;
/**
* 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[]>;
/**
* Take a screenshot of the whole page.
* @returns Returns a base64 encoded png.
* @see https://w3c.github.io/webdriver/#dfn-take-screenshot
*/
screenshot(): Promise<string>;
/**
* Perform actions on the webdriver.
* @param actions The actions to perform.
* @returns True if the actions were successfully performed.
*/
actions(actions: WebDriverAction[]): Promise<boolean>;
}