UNPKG

@assert-equals/dappdriver

Version:

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

66 lines (65 loc) 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CheckBox = void 0; const constants_1 = require("../constants"); const check_box_1 = require("../playwright/check-box"); const dapp_driver_1 = require("../session/dapp-driver"); const check_box_2 = require("../webdriver/check-box"); const html_element_1 = require("./html-element"); /** * * * @export * @class CheckBox * @extends {HTMLElement} * @implements {ICheckBox} */ class CheckBox extends html_element_1.HTMLElement { /** * Creates an instance of CheckBox. * @param {string} cssLocator * @memberof CheckBox */ constructor(cssLocator) { super(cssLocator); } /** * * * @protected * @param {(keyof IHTMLElement | keyof ICheckBox)} methodName * @param {Array<any>} [args=[]] * @return {*} {Promise<any>} * @memberof CheckBox */ async callIfMethodExists(methodName, args = []) { let checkbox; if (dapp_driver_1.DappDriver.Instance.Framework === constants_1.PLAYWRIGHT) { checkbox = new check_box_1.PlaywrightCheckBox(this.cssLocator); } else if (dapp_driver_1.DappDriver.Instance.Framework === constants_1.WEBDRIVER) { checkbox = new check_box_2.WebDriverCheckBox(this.cssLocator); } return await checkbox[methodName](...args); } /** * * Schedules a command to check or uncheck this element * @param {boolean} value * @return {*} {Promise<void>} * @memberof CheckBox */ async setValue(value) { return await this.callIfMethodExists('setValue', [value]); } /** * * Schedules a command to query whether this element is currently checked * @return {*} {Promise<boolean>} * @memberof CheckBox */ async isSelected() { return await this.callIfMethodExists('isSelected'); } } exports.CheckBox = CheckBox;