import webdriver, { Capabilities, WebDriver, WebElement as WebElementShape } from 'selenium-webdriver'; import Variables from './variables'; import { Fn } from '@seleniumhq/side-commons'; import { CommandShape } from '@seleniumhq/side-model'; import { PluginRuntimeShape, StoreWindowHandleHookInput, WindowAppearedHookInput, WindowSwitchedHookInput } from './types'; export type ExpandedCapabilities = Partial & { browserName: string; 'goog:chromeOptions'?: Record; }; declare const state: unique symbol; /** * This is a polyfill type to allow for unsupported electron * driver methods to override with their own custom implementations */ export interface WindowAPI { setWindowSize: (executor: WebDriverExecutor, width: number, height: number) => Promise; } export interface WebDriverExecutorConstructorArgs { capabilities?: ExpandedCapabilities; customCommands?: PluginRuntimeShape['commands']; disableCodeExportCompat?: boolean; driver?: WebDriver; hooks?: WebDriverExecutorHooks; implicitWait?: number; server?: string; } export interface WebDriverExecutorInitOptions { baseUrl: string; debug?: boolean; logger: Console; variables: Variables; } export interface WebDriverExecutorCondEvalResult { value: boolean; } export interface BeforePlayHookInput { driver: WebDriverExecutor; } export interface CommandHookInput { command: CommandShape; } export type GeneralHook = (input: T) => Promise | void; export interface WebDriverExecutorHooks { onBeforePlay?: GeneralHook; onAfterCommand?: GeneralHook; onBeforeCommand?: GeneralHook; onStoreWindowHandle?: GeneralHook; onWindowAppeared?: GeneralHook; onWindowSwitched?: GeneralHook; } export type HookKeys = keyof WebDriverExecutorHooks; export interface ElementEditableScriptResult { enabled: boolean; readonly: boolean; } export interface ScriptShape { script: string; argv: any[]; } export default class WebDriverExecutor { constructor({ customCommands, disableCodeExportCompat, driver, capabilities, server, hooks, implicitWait, }: WebDriverExecutorConstructorArgs); baseUrl?: string; variables: Variables; cancellable?: { cancel: () => void; }; capabilities?: ExpandedCapabilities; customCommands: Required['commands']; disableCodeExportCompat: boolean; driver: WebDriver; server?: string; windowHandle?: string; hooks: WebDriverExecutorHooks; implicitWait: number; initialized: boolean; logger?: Console; [state]?: any; getDriverSync({ debug, logger, }: Pick): webdriver.ThenableWebDriver; getDriver({ debug, logger, }: Pick): Promise; init({ baseUrl, debug, logger, variables, }: WebDriverExecutorInitOptions): Promise; cancel(): Promise; cleanup(persistSession?: boolean): Promise; isAlive(): boolean; name(command: string): string; nameTransform(command: string): string; executeHook(hook: T, ...args: Parameters>): Promise; beforeCommand(commandObject: CommandShape): Promise; afterCommand(commandObject: CommandShape): Promise; waitForNewWindow(timeout?: number): Promise; registerCommand(commandName: string, fn: Fn): void; skip(): Promise; doOpen(url: string): Promise; doSetWindowSize(widthXheight: string): Promise; doSelectWindow(handleLocator: string): Promise; doClose(): Promise; doSelectFrame(locator: string): Promise; doAddSelection(locator: string, optionLocator: string, commandObject?: Partial): Promise; doRemoveSelection(locator: string, optionLocator: string, commandObject?: Partial): Promise; doCheck(locator: string, _: string, commandObject?: Partial): Promise; doUncheck(locator: string, _: string, commandObject?: Partial): Promise; doClick(locator: string, _?: string, commandObject?: Partial): Promise; doClickAt(locator: string, coordString: string, commandObject?: Partial): Promise; doDoubleClick(locator: string, _?: string, _commandObject?: Partial): Promise; doDoubleClickAt(locator: string, coordString: string, commandObject?: Partial): Promise; doDragAndDropToObject(dragLocator: string, dropLocator: string, commandObject?: Partial): Promise; doMouseDown(locator: string, _?: string, _commandObject?: Partial): Promise; doMouseDownAt(locator: string, coordString: string, commandObject?: Partial): Promise; doMouseMoveAt(locator: string, coordString: string, commandObject?: Partial): Promise; doMouseOut(locator: string, _?: string, _commandObject?: Partial): Promise; doMouseOver(locator: string, _?: string, _commandObject?: Partial): Promise; doMouseUp(locator: string, _?: string, _commandObject?: Partial): Promise; doMouseUpAt(locator: string, coordString: string, commandObject?: Partial): Promise; doSelect(locator: string, optionLocator: string, commandObject?: Partial): Promise; doSubmit(locator: string, _?: string, _commandObject?: Partial): Promise; doEditContent(locator: string, value: string, commandObject?: Partial): Promise; doType(locator: string, value: string, commandObject?: Partial): Promise; doSendKeys(locator: string, value: string, commandObject?: Partial): Promise; doWaitForElementEditable(locator: string, timeout: string): Promise; doWaitForElementNotEditable(locator: string, timeout: string): Promise; doWaitForElementPresent(locator: string, timeout: string, commandObj?: Partial): Promise; doWaitForElementNotPresent(locator: string, timeout: string): Promise; doWaitForElementVisible(locator: string, timeout: string, commandObj?: Partial): Promise; doWaitForElementNotVisible(locator: string, timeout: string): Promise; doWaitForText(locator: string, text: string, commandObj?: Partial): Promise; doRunScript(script: ScriptShape): Promise; doExecuteScript(script: ScriptShape, optionalVariable?: string): Promise; doExecuteAsyncScript(script: ScriptShape, optionalVariable?: string): Promise; doAcceptAlert(): Promise; doAcceptConfirmation(): Promise; doAnswerPrompt(optAnswer?: string): Promise; doDismissConfirmation(): Promise; doDismissPrompt(): Promise; doStore(string: string, variable: string): Promise; doStoreAttribute(attributeLocator: string, variable: string): Promise; doStoreElementCount(locator: string, variable: string): Promise; doStoreJson(json: string, variable: string): Promise; doStoreText(locator: string, variable: string, commandObject?: Partial): Promise; doStoreTitle(variable: string): Promise; doStoreValue(locator: string, variable: string, commandObject?: Partial): Promise; doStoreWindowHandle(variable: string): Promise; doAssert(variableName: string, value: string): Promise; doAssertAlert(expectedText: string): Promise; doAssertConfirmation(expectedText: string): Promise; doAssertEditable(locator: string, _?: string, _commandObject?: Partial): Promise; doAssertNotEditable(locator: string, _?: string, _commandObject?: Partial): Promise; doAssertPrompt(expectedText: string): Promise; doAssertTitle(title: string): Promise; doAssertElementPresent(locator: string, _: string, commandObject?: Partial): Promise; doAssertElementNotPresent(locator: string): Promise; doAssertText(locator: string, value: string, commandObject?: Partial): Promise; doAssertNotText(locator: string, value: string, commandObject?: Partial): Promise; doAssertValue(locator: string, value: string, commandObject?: Partial): Promise; doAssertNotValue(locator: string, value: string, commandObject?: Partial): Promise; doAssertChecked(locator: string, _: string, commandObject?: Partial): Promise; doAssertNotChecked(locator: string, _: string, commandObject?: Partial): Promise; doAssertSelectedValue(locator: string, value: string, commandObject?: Partial): Promise; doAssertNotSelectedValue(locator: string, value: string, commandObject?: Partial): Promise; doAssertSelectedLabel(locator: string, label: string, commandObject?: Partial): Promise; doAssertNotSelectedLabel(locator: string, label: string, commandObject?: Partial): Promise; doDebugger(): Promise; doEcho(string: string): Promise; doPause(time: number): Promise; doRun(): Promise; doSetSpeed(): Promise; evaluateConditional(script: ScriptShape): Promise; elementIsLocated(locator: string, ..._fallbacks: (undefined | [string, string][])[]): Promise; withCancel Promise>(poller: T): () => Promise; waitForElement(locator: string, ...fallbacks: (undefined | [string, string][])[]): Promise; isElementEditable(element: WebElementShape): Promise; waitForElementVisible(locator: string, timeout: number, ...fallbacks: (undefined | [string, string][])[]): Promise; waitForText(locator: string, text: string, fallback?: [string, string][]): Promise; } export {}; //# sourceMappingURL=webdriver.d.ts.map