UNPKG

@assert-equals/dappdriver

Version:

DappDriver is an e2e testing framework designed for testing decentralized applications (dApps) using MetaMask, Rainbow or Zerion

302 lines (301 loc) 8.96 kB
import { IPageObject } from '../interface/page/page-object'; import { IConfirmation } from '../interface/wallet/confirmation'; import { Comparator, Cookie } from '../types'; /** * * * @export * @class PageObject * @implements {IPageObject} */ export declare class PageObject implements IPageObject { private page; url: string | RegExp; title: string; /** * Creates an instance of PageObject. * @param {(string | RegExp)} [url=''] * @param {string} [title=''] * @memberof PageObject */ constructor(url?: string | RegExp, title?: string); /** * * * @param {(string | RegExp)} url * @param {string} title * @memberof PageObject */ initialize(url: string | RegExp, title: string): void; /** * * * @private * @param {keyof IPageObject} methodName * @param {Array<any>} [args=[]] * @return {*} {Promise<any>} * @memberof PageObject */ private callIfMethodExists; /** * * * @private * @param {string} url * @return {*} {string} * @memberof PageObject */ private getFullURL; /** * * * @param {Cookie} cookie * @return {*} {Promise<void>} * @memberof PageObject */ addCookie(cookie: Cookie): Promise<void>; /** * * Schedules a command to navigate backwards in the browser history * @template TPage * @param {new () => TPage} page * @return {*} {Promise<TPage>} * @memberof PageObject */ back<TPage>(page: new () => TPage): Promise<TPage>; /** * * * @param {string} name * @return {*} {Promise<void>} * @memberof PageObject */ clearCookie(name: string): Promise<void>; /** * * * @return {*} {Promise<void>} * @memberof PageObject */ clearCookies(): Promise<void>; /** * * Schedules a command to close the current window * @template TPage * @param {new () => TPage} page * @return {*} {Promise<TPage>} * @memberof PageObject */ close<TPage>(page: new () => TPage): Promise<TPage>; /** * * Schedules a command to close the current window and switch the focus of all future commands to a given window * @template TPage * @param {new () => TPage} page * @return {*} {Promise<TPage>} * @memberof PageObject */ closeAndSwitchToWindow<TPage extends IConfirmation | IPageObject>(page: new () => TPage): Promise<TPage>; /** * * Schedules a command to execute JavaScript in the context of the currently selected frame or window * @param {string} script * @return {*} {Promise<any>} * @memberof PageObject */ executeScript(script: string): Promise<any>; /** * * Schedules a command to execute JavaScript in the context of the currently selected frame or window and switch the focus of all future commands to a given window * @template TPage * @param {string} script * @param {new () => TPage} page * @return {*} {Promise<any>} * @memberof PageObject */ executeScriptAndSwitchToWindow<TPage extends IConfirmation | IPageObject>(script: string, page: new () => TPage): Promise<TPage>; /** * * Schedules a command to navigate forwards in the browser history * @template TPage * @param {new () => TPage} page * @return {*} {Promise<TPage>} * @memberof PageObject */ forward<TPage>(page: new () => TPage): Promise<TPage>; /** * * Schedules a command to retrieve the current list of available window handles * @return {*} {Promise<Array<any>>} * @memberof PageObject */ getAllWindowHandles(): Promise<Array<any>>; /** * * * @param {string} name * @return {*} {Promise<any>} * @memberof PageObject */ getCookie(name: string): Promise<any>; /** * * * @return {*} {Promise<Array<any>>} * @memberof PageObject */ getCookies(): Promise<Array<any>>; /** * * Schedules a command to retrieve the URL of the current page * @return {*} {Promise<string>} * @memberof PageObject */ getCurrentUrl(): Promise<string>; /** * * Schedules a command to retrieve the HTML source of the current page * @return {*} {Promise<string>} * @memberof PageObject */ getPageSource(): Promise<string>; /** * * Schedules a command to retrieve the current page title * @return {*} {Promise<string>} * @memberof PageObject */ getTitle(): Promise<string>; /** * * Schedules a command to retrieve the current window handle * @return {*} {Promise<any>} * @memberof PageObject */ getWindowHandle(): Promise<any>; /** * * Schedules a command to maximize the window * @return {*} {Promise<void>} * @memberof PageObject */ maximize(): Promise<void>; /** * * Schedules a command to navigate to a new URL * @template TPage * @param {string} url * @param {new () => TPage} page * @return {*} {Promise<TPage>} * @memberof PageObject */ navigateTo<TPage>(url: string, page: new () => TPage): Promise<TPage>; /** * * Schedules a command to navigate to a new page in a new window * @template TPage * @param {string} url * @param {new () => TPage} page * @return {*} {Promise<TPage>} * @memberof PageObject */ navigateToPageInNewWindow<TPage>(url: string, page: new () => TPage): Promise<TPage>; /** * * Schedules a command to refresh the current page * @template TPage * @param {new () => TPage} page * @return {*} {Promise<TPage>} * @memberof PageObject */ refresh<TPage>(page: new () => TPage): Promise<TPage>; /** * * Schedules a command to resize the window * @param {number} width * @param {number} height * @return {*} {Promise<void>} * @memberof PageObject */ setSize(width: number, height: number): Promise<void>; /** * * Schedules a command to switch focus of all future commands to the topmost frame on the page * @return {*} {Promise<void>} * @memberof PageObject */ switchBack(): Promise<void>; /** * * Schedules a command to switch the focus of all future commands to another frame on the page * @param {string} cssLocator * @return {*} {Promise<void>} * @memberof PageObject */ switchToFrame(cssLocator: string): Promise<void>; /** * * Schedules a command to switch the focus of all future commands to a given window * whose title and url match the provided page * @template TPage * @param {new () => TPage} page * @return {*} {Promise<TPage>} * @memberof PageObject */ switchToWindow<TPage extends IConfirmation | IPageObject>(page: new () => TPage): Promise<TPage>; /** * * Schedules a command to wait for the required count of windows to be opened * and switch the focus of all future commands to the first matching window * @template TPage * @param {number} total * @param {Comparator} comparator * @param {new () => TPage} page * @return {*} {Promise<TPage>} * @memberof PageObject */ waitAndSwitchToWindow<TPage extends IConfirmation | IPageObject>(page: new () => TPage, total?: number, comparator?: Comparator): Promise<TPage>; /** * * Schedules a command to wait for an element to appear * @param {string} cssLocator * @return {*} {Promise<void>} * @memberof PageObject */ waitForElement(cssLocator: string): Promise<void>; /** * * Schedules a command to wait for a function to return a truthy value * @param {Function} func * @param {string} errMsg * @param {number} [timeout=10_000] * @return {*} {Promise<void>} * @memberof PageObject */ waitForFunction(func: Function, errMsg: string, timeout?: number): Promise<void>; /** * * Schedules a command to wait for the required title to be returned * @param {RegExp} [title] * @return {*} {Promise<void>} * @memberof PageObject */ waitForTitle(title?: RegExp): Promise<void>; /** * * Schedules a command to wait for the current page to navigate to the given URL * @param {RegExp} [url] * @return {*} {Promise<void>} * @memberof PageObject */ waitForURL(url?: RegExp): Promise<void>; /** * * Schedules a command to wait for the required count of windows to be opened * @param {number} total * @param {Comparator} comparator * @return {*} {Promise<void>} * @memberof PageObject */ waitForWindows(total: number, comparator: Comparator): Promise<void>; }