@assert-equals/dappdriver
Version:
DappDriver is an e2e testing framework designed for testing decentralized applications (dApps) using MetaMask, Rainbow or Zerion
317 lines (316 loc) • 9.35 kB
TypeScript
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 to the previous URL
* @template TPage
* @param {new () => TPage} [page]
* @return {*} {Promise<any>}
* @memberof PageObject
*/
back(): Promise<void>;
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<any>}
* @memberof PageObject
*/
close(): Promise<void>;
close<TPage>(page: new () => TPage): Promise<TPage>;
/**
*
* Schedules a command to close the current window and switch the focus of all future commands to the main window
* @template TPage
* @param {new () => TPage} [page]
* @return {*} {Promise<any>}
* @memberof PageObject
*/
closeAndSwitchToMainWindow(): Promise<void>;
closeAndSwitchToMainWindow<TPage>(page: new () => TPage): Promise<TPage>;
/**
*
* Schedules a command to open a new window
* @return {*} {Promise<void>}
* @memberof PageObject
*/
createNewWindow(): Promise<void>;
/**
*
* 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 the window
* @template TPage
* @param {string} script
* @param {new () => TPage} page
* @return {*} {Promise<any>}
* @memberof PageObject
*/
executeScriptAndOpensInWindow<TPage extends IConfirmation | IPageObject>(script: string, page: new () => TPage): Promise<any>;
/**
*
* 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 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<any>}
* @memberof PageObject
*/
navigateTo(url: string): Promise<void>;
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<any>}
* @memberof PageObject
*/
navigateToPageInNewWindow(url: string): Promise<void>;
navigateToPageInNewWindow<TPage>(url: string, page: new () => TPage): Promise<TPage>;
/**
*
* Schedules a command to switch the focus of all future commands to another window
* @template TPage
* @param {new () => TPage} [page]
* @return {*} {Promise<any>}
* @memberof PageObject
*/
opensInNewWindow(): Promise<void>;
opensInNewWindow<TPage>(page: new () => TPage): Promise<TPage>;
/**
*
* Schedules a command to switch the focus of all future commands to the window
* @template TPage
* @param {new () => TPage} page
* @return {*} {Promise<TPage>}
* @memberof PageObject
*/
opensInWindow<TPage extends IConfirmation | IPageObject>(page: new () => TPage): Promise<TPage>;
/**
*
* Schedules a command to refresh the current page
* @template TPage
* @param {new () => TPage} [page]
* @return {*} {Promise<any>}
* @memberof PageObject
*/
refresh(): Promise<void>;
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 the main window
* @template TPage
* @param {new () => TPage} [page]
* @return {*} {Promise<any>}
* @memberof PageObject
*/
switchToMainWindow(): Promise<void>;
switchToMainWindow<TPage>(page: new () => TPage): Promise<TPage>;
/**
*
* Schedules a command to switch the focus of all future commands to a given window
* @template TPage
* @param {*} nameOrHandle
* @param {new () => TPage} [page]
* @return {*} {Promise<any>}
* @memberof PageObject
*/
switchToWindow(nameOrHandle: any): Promise<void>;
switchToWindow<TPage>(nameOrHandle: any, page: new () => TPage): 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
* @param {number} total
* @param {Comparator} comparator
* @return {*} {Promise<Array<any>>}
* @memberof PageObject
*/
waitForWindows(total: number, comparator?: Comparator): Promise<Array<any>>;
}