@assert-equals/dappdriver
Version:
DappDriver is an e2e testing framework designed for testing decentralized applications (dApps) using MetaMask, Rainbow or Zerion
113 lines (112 loc) • 3.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.InputText = void 0;
const constants_1 = require("../constants");
const input_text_1 = require("../playwright/input-text");
const dapp_driver_1 = require("../session/dapp-driver");
const input_text_2 = require("../webdriver/input-text");
const html_element_1 = require("./html-element");
/**
*
*
* @export
* @class InputText
* @extends {HTMLElement}
* @implements {IInputText}
*/
class InputText extends html_element_1.HTMLElement {
/**
* Creates an instance of InputText.
* @param {string} cssLocator
* @memberof InputText
*/
constructor(cssLocator) {
super(cssLocator);
}
/**
*
*
* @protected
* @param {(keyof IHTMLElement | keyof IInputText)} methodName
* @param {Array<any>} [args=[]]
* @return {*} {Promise<any>}
* @memberof InputText
*/
async callIfMethodExists(methodName, args = []) {
let inputText;
if (dapp_driver_1.DappDriver.Instance.Framework === constants_1.PLAYWRIGHT) {
inputText = new input_text_1.PlaywrightInputText(this.cssLocator);
}
else if (dapp_driver_1.DappDriver.Instance.Framework === constants_1.WEBDRIVER) {
inputText = new input_text_2.WebDriverInputText(this.cssLocator);
}
return await inputText[methodName](...args);
}
/**
*
* Schedules a command to clear the value of this element
* @return {*} {Promise<void>}
* @memberof InputText
*/
async clear() {
return await this.callIfMethodExists('clear');
}
/**
*
* Schedules a command to focus in this element
* @return {*} {Promise<void>}
* @memberof InputText
*/
async focus() {
return await this.callIfMethodExists('focus');
}
/**
*
* Schedules a command to query for the value attribute of the element
* @return {*} {Promise<string>}
* @memberof InputText
*/
async getText() {
return await this.callIfMethodExists('getText');
}
/**
*
* Schedules a command to query for the value attribute of the element
* @return {*} {Promise<string>}
* @memberof InputText
*/
async getValue() {
return await this.callIfMethodExists('getValue');
}
/**
*
* Schedules a command to type a sequence in the element
* @param {string} keys
* @return {*} {Promise<void>}
* @memberof InputText
*/
async type(keys) {
return await this.callIfMethodExists('type', [keys]);
}
/**
*
* Schedules a command to type a sequence in the element
* @param {string} keys
* @return {*} {Promise<void>}
* @memberof InputText
*/
async typeAndEnter(keys) {
return await this.callIfMethodExists('typeAndEnter', [keys]);
}
/**
*
* Schedules a command to type a sequence in the element
* @param {string} keys
* @return {*} {Promise<void>}
* @memberof InputText
*/
async typeAndTab(keys) {
return await this.callIfMethodExists('typeAndTab', [keys]);
}
}
exports.InputText = InputText;