@vibe/testkit
Version:
Vibe e2e testing toolkit
73 lines • 2.89 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextField = void 0;
const test_1 = require("@playwright/test");
const common_actions_1 = require("../utils/common-actions");
const BaseElement_1 = require("./BaseElement");
/**
* Class representing a TextField element.
* Extends the BaseElement class.
*/
class TextField extends BaseElement_1.BaseElement {
/**
* Create a TextField.
* @param {Page} page - The Playwright page object.
* @param {Locator} locator - The locator for the TextField element.
* @param {string} elementReportName - The name for reporting purposes.
*/
constructor(page, locator, elementReportName) {
super(page, locator, elementReportName);
}
/**
* Set specified text in input element.
* @param {string} text - Text to be filled in the input.
* @returns {Promise<void>}
*/
setText(text) {
return __awaiter(this, void 0, void 0, function* () {
yield test_1.test.step(`Set text: ${text} in element: ${this.elementReportName}`, () => __awaiter(this, void 0, void 0, function* () {
yield this.clearText();
yield this.locator.fill(text);
}));
});
}
/**
* Clear the text in the input element.
*/
clearText() {
return __awaiter(this, void 0, void 0, function* () {
yield test_1.test.step(`Clear text in element: ${this.elementReportName}`, () => __awaiter(this, void 0, void 0, function* () {
yield this.locator.fill("");
}));
});
}
/**
* Get the value of the input element.
* @returns {Promise<string>}
*/
isEmpty() {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.locator.inputValue()) === "";
});
}
/**
* Exit the edit mode by pressing the Escape key.
* @returns {Promise<void>}
*/
exitEditMode() {
return __awaiter(this, void 0, void 0, function* () {
yield (0, common_actions_1.pressKey)(this.page, "Escape");
});
}
}
exports.TextField = TextField;
//# sourceMappingURL=TextField.js.map