@assert-equals/dappdriver
Version:
DappDriver is an e2e testing framework designed for testing decentralized applications (dApps) using MetaMask, Rainbow or Zerion
65 lines (64 loc) • 1.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Radio = void 0;
const constants_1 = require("../constants");
const radio_1 = require("../playwright/radio");
const dapp_driver_1 = require("../session/dapp-driver");
const radio_2 = require("../webdriver/radio");
const html_element_1 = require("./html-element");
/**
*
*
* @export
* @class Radio
* @extends {HTMLElement}
* @implements {IRadio}
*/
class Radio extends html_element_1.HTMLElement {
/**
* Creates an instance of Radio.
* @param {string} cssLocator
* @memberof Radio
*/
constructor(cssLocator) {
super(cssLocator);
}
/**
*
*
* @protected
* @param {(keyof IHTMLElement | keyof IRadio)} methodName
* @param {Array<any>} [args=[]]
* @return {*} {Promise<any>}
* @memberof Radio
*/
async callIfMethodExists(methodName, args = []) {
let radio;
if (dapp_driver_1.DappDriver.Instance.Framework === constants_1.PLAYWRIGHT) {
radio = new radio_1.PlaywrightRadio(this.cssLocator);
}
else if (dapp_driver_1.DappDriver.Instance.Framework === constants_1.WEBDRIVER) {
radio = new radio_2.WebDriverRadio(this.cssLocator);
}
return await radio[methodName](...args);
}
/**
*
* Schedules a command to query whether this element is currently selected
* @return {*} {Promise<boolean>}
* @memberof Radio
*/
async isSelected() {
return await this.callIfMethodExists('isSelected');
}
/**
*
* Schedules a command to select this element
* @return {*} {Promise<void>}
* @memberof Radio
*/
async select() {
return await this.callIfMethodExists('select');
}
}
exports.Radio = Radio;