UNPKG

@openfin/automation-helpers

Version:

Helper methods for automation testing in the OpenFin ecosystem

133 lines (132 loc) 3.17 kB
import type { IWebDriverElement } from "./IWebDriverElement"; import type { MouseButton } from "./mouseButton"; /** * Base web driver action interface. */ export interface BaseWebDriverAction { /** * The type of the action. */ type: string; } /** * Simulate button down to the current mouse position. */ export type WebDriverMouseDownAction = BaseWebDriverAction & { /** * The type for the action. */ type: "mouseDown"; /** * The button on the mouse to send the action. */ button?: MouseButton; }; /** * Simulate button up to the current mouse position. */ export type WebDriverMouseUpAction = BaseWebDriverAction & { /** * The type for the action. */ type: "mouseUp"; /** * The button on the mouse to send the action. */ button?: MouseButton; }; /** * Shortcut combination of mouseDown and mouseUp for simulate click. */ export type WebDriverMouseClickAction = BaseWebDriverAction & { /** * The type for the action. */ type: "mouseClick"; /** * The button on the mouse to send the action. */ button?: MouseButton; }; /** * Move mouse to position on screen or relative to element. * Defaults to element center if no position provided, or offset from top left if position provided. */ export type WebDriverMouseMoveAction = BaseWebDriverAction & { /** * The type for the action. */ type: "mouseMove"; /** * The x position to send the action. */ x?: number; /** * The y position to send the action. */ y?: number; /** * The reference origin to mouse the mouse. */ origin?: "pointer" | "viewport" | IWebDriverElement; /** * Duration in milliseconds to perform the action. */ duration?: number; }; /** * Simulate key down to the current focused element. */ export type WebDriverKeyDownAction = BaseWebDriverAction & { /** * The type for the action. */ type: "keyDown"; /** * The key to send the action. */ key: string; }; /** * Simulate key up to the current focused element. */ export type WebDriverKeyUpAction = BaseWebDriverAction & { /** * The type for the action. */ type: "keyUp"; /** * The key to send the action. */ key: string; }; /** * Shortcut combination of keyDown and keyUp to the current focused element. */ export type WebDriverKeyPressAction = BaseWebDriverAction & { /** * The type for the action. */ type: "keyPress"; /** * The key or keys to send the action. */ key: string; }; /** * Perform a pause in the actions. */ export type WebDriverPauseAction = BaseWebDriverAction & { /** * The type for the action. */ type: "pause"; /** * Duration in milliseconds to pause for. */ duration: number; }; /** * All of the web driver actions. */ export type WebDriverAction = WebDriverMouseDownAction | WebDriverMouseUpAction | WebDriverMouseClickAction | WebDriverMouseMoveAction | WebDriverKeyDownAction | WebDriverKeyUpAction | WebDriverKeyPressAction | WebDriverPauseAction;