UNPKG

@assert-equals/dappdriver

Version:

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

55 lines (54 loc) 1.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HTMLElementCollection = void 0; const constants_1 = require("../constants"); const html_element_collection_1 = require("../playwright/html-element-collection"); const dapp_driver_1 = require("../session/dapp-driver"); const html_element_collection_2 = require("../webdriver/html-element-collection"); /** * * * @export * @class HTMLElementCollection * @implements {IHTMLElementCollection} */ class HTMLElementCollection { cssLocator; /** * Creates an instance of HTMLElementCollection. * @param {string} cssLocator * @memberof HTMLElementCollection */ constructor(cssLocator) { this.cssLocator = cssLocator; } /** * * * @protected * @param {keyof IHTMLElementCollection} methodName * @param {Array<any>} [args=[]] * @return {*} {Promise<any>} * @memberof HTMLElementCollection */ async callIfMethodExists(methodName, args = []) { let htmlElementCollection; if (dapp_driver_1.DappDriver.Instance.Framework === constants_1.PLAYWRIGHT) { htmlElementCollection = new html_element_collection_1.PlaywrightHTMLElementCollection(this.cssLocator); } else if (dapp_driver_1.DappDriver.Instance.Framework === constants_1.WEBDRIVER) { htmlElementCollection = new html_element_collection_2.WebDriverHTMLElementCollection(this.cssLocator); } return await htmlElementCollection[methodName](...args); } /** * * Schedules a command to retrieve the elements * @return {*} {Promise<Array<HTMLElement>>} * @memberof HTMLElementCollection */ async elements() { return await this.callIfMethodExists('elements'); } } exports.HTMLElementCollection = HTMLElementCollection;