@assert-equals/dappdriver
Version:
DappDriver is an e2e testing framework designed for testing decentralized applications (dApps) using MetaMask, Rainbow or Zerion
62 lines (61 loc) • 1.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SignatureRequest = void 0;
const html_element_1 = require("../../controls/html-element");
const page_1 = require("../../page");
/**
*
*
* @export
* @class SignatureRequest
* @extends {PageObject}
* @implements {IConfirmation}
*/
class SignatureRequest extends page_1.PageObject {
scrollButton = () => new html_element_1.HTMLElement('xpath=//button[contains(., "Scroll")]');
signButton = () => new html_element_1.HTMLElement('xpath=//button[contains(., "Sign")]');
cancelButton = () => new html_element_1.HTMLElement('xpath=//button[contains(., "Cancel")]');
/**
* Creates an instance of SignatureRequest.
* @memberof SignatureRequest
*/
constructor() {
super('#/signTypedData', 'Zerion · Sign Typed Data');
}
/**
*
*
* @template TPage
* @param {new () => TPage} [page]
* @return {*} {Promise<any>}
* @memberof SignatureRequest
*/
async accept(page) {
if (await this.scrollButton().isDisplayed()) {
await this.scrollButton().clickAndWait();
}
if (page) {
return await this.signButton().clickAndSwitchToMainWindow(page);
}
else {
return await this.signButton().click();
}
}
/**
*
*
* @template TPage
* @param {new () => TPage} [page]
* @return {*} {Promise<any>}
* @memberof SignatureRequest
*/
async reject(page) {
if (page) {
return await this.cancelButton().clickAndSwitchToMainWindow(page);
}
else {
return await this.cancelButton().click();
}
}
}
exports.SignatureRequest = SignatureRequest;