UNPKG

@assert-equals/dappdriver

Version:

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

56 lines (55 loc) 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Link = void 0; const constants_1 = require("../constants"); const link_1 = require("../playwright/link"); const dapp_driver_1 = require("../session/dapp-driver"); const link_2 = require("../webdriver/link"); const html_element_1 = require("./html-element"); /** * * * @export * @class Link * @extends {HTMLElement} * @implements {ILink} */ class Link extends html_element_1.HTMLElement { /** * Creates an instance of Link. * @param {string} cssLocator * @memberof Link */ constructor(cssLocator) { super(cssLocator); } /** * * * @protected * @param {(keyof IHTMLElement | keyof ILink)} methodName * @param {Array<any>} [args=[]] * @return {*} {Promise<any>} * @memberof Link */ async callIfMethodExists(methodName, args = []) { let link; if (dapp_driver_1.DappDriver.Instance.Framework === constants_1.PLAYWRIGHT) { link = new link_1.PlaywrightLink(this.cssLocator); } else if (dapp_driver_1.DappDriver.Instance.Framework === constants_1.WEBDRIVER) { link = new link_2.WebDriverLink(this.cssLocator); } return await link[methodName](...args); } /** * * Schedules a command to query for the href attribute of the element * @return {*} {Promise<string>} * @memberof Link */ async location() { return await this.callIfMethodExists('location'); } } exports.Link = Link;