UNPKG

@openfin/automation-helpers

Version:

Helper methods for automation testing in the OpenFin ecosystem

127 lines (126 loc) 5.34 kB
import type OpenFin from "@openfin/core"; import { type ThenableWebDriver } from "selenium-webdriver"; import type { IWebDriver } from "../models/IWebDriver"; import type { IWebDriverElement } from "../models/IWebDriverElement"; import type { LocatorTypes } from "../models/locatorTypes"; import type { WebDriverAction } from "../models/webDriverAction"; import { BaseWebDriver } from "./baseWebDriver"; import { SeleniumWebDriverWindow } from "./seleniumWebDriverWindow"; /** * Webdriver for the Selenium environment. */ export declare class SeleniumWebDriver extends BaseWebDriver<ThenableWebDriver, SeleniumWebDriverWindow> implements IWebDriver { /** * Interval timer for logging. */ private _logTimer?; /** * Create a new instance of SeleniumWebDriver. * @param webDriver The web driver to use for chromedriver calls if already started. */ constructor(webDriver?: ThenableWebDriver); /** * 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. * @see https://w3c.github.io/webdriver/#dfn-new-sessions * @returns Nothing. */ 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>; /** * 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[]>; /** * 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>; /** * Create the native window object. * @param client The client. * @param windowHandle The window handle. * @param title The window title. * @param url The window url. * @param identity The window identity. * @returns The native window. */ protected createWebDriverWindow(client: ThenableWebDriver, windowHandle: string, title: string, url: string, identity: OpenFin.Identity | undefined): SeleniumWebDriverWindow; /** * Get the title of the current window. * @returns The window title. * @see https://w3c.github.io/webdriver/#dfn-get-title */ protected safeGetTitle(): Promise<string | undefined>; /** * Get the URL of the current window. * @returns The window url. * @see https://w3c.github.io/webdriver/#dfn-get-current-url */ protected safeGetUrl(): Promise<string | undefined>; /** * Set the URL of the current window. * @param url The url to navigate to. * @see https://w3c.github.io/webdriver/#dfn-navigate-to */ protected safeSetUrl(url: string): Promise<void>; /** * Get the window handle and catch exceptions. * @returns The window handle if available. */ protected safeGetWindowHandle(): Promise<string | undefined>; /** * Get the window handles and catch exceptions. * @returns The window handles if available. */ protected safeGetWindowHandles(): Promise<string[]>; /** * Switch to the window handle and catch exceptions. * @param handle The window to switch to. * @param activateNativeWindow Activate the native window as well. * @returns True if switched to the window. */ protected safeSwitchToWindow(handle: string, activateNativeWindow: boolean): Promise<boolean>; }