UNPKG

@vibe/testkit

Version:
91 lines 3.88 kB
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()); }); }; import { test } from "@playwright/test"; import { pressKey } from "../utils/common-actions"; import { BaseElement } from "./BaseElement"; import { Button } from "./Button"; import { Text } from "./Text"; /** * Class representing a TextArea element. * Extends the BaseElement class. */ export class TextArea extends BaseElement { /** * Create a TextArea element. * @param {Page} page - The Playwright page object. * @param {Locator} locator - The locator for the TextArea element. * @param {string} elementReportName - The name for reporting purposes. */ constructor(page, locator, elementReportName) { super(page, locator, elementReportName); this.wrapper = new Button(page, locator, `${elementReportName} - Wrapper`); this.input = new Text(page, locator.locator("textarea"), `${elementReportName} - Input`); } /** * Set specified text in text area. * @param {string} text - Text to be filled in the text area. * @returns {Promise<void>} */ setText(text) { return __awaiter(this, void 0, void 0, function* () { yield test.step(`Set text: ${text} for ${this.getElementReportName()}`, () => __awaiter(this, void 0, void 0, function* () { yield this.wrapper.click(); yield this.input.waitForElementToBeVisible(); yield this.input.getLocator().fill(text); yield this.exitEditMode(); })); }); } /** * Clear the text from the text area. * @returns {Promise<void>} */ clearText() { return __awaiter(this, void 0, void 0, function* () { yield test.step(`Clear text for ${this.getElementReportName()}`, () => __awaiter(this, void 0, void 0, function* () { yield this.input.getLocator().clear(); })); }); } /** * Get the text from the text area. * @returns {Promise<string>} The text from the text area. */ getText() { return __awaiter(this, void 0, void 0, function* () { return yield test.step(`Get text for ${this.getElementReportName()}`, () => __awaiter(this, void 0, void 0, function* () { return yield this.input.getLocator().inputValue(); })); }); } /** * Check if the text area is empty. * @returns {Promise<boolean>} True if the text area is empty. */ isEmpty() { return __awaiter(this, void 0, void 0, function* () { return yield test.step(`Check if text area is empty for ${this.getElementReportName()}`, () => __awaiter(this, void 0, void 0, function* () { return (yield this.input.getLocator().inputValue()) === ""; })); }); } /** * Exit the edit mode by pressing the Escape key. * @returns {Promise<void>} */ exitEditMode() { return __awaiter(this, void 0, void 0, function* () { yield test.step("Exit edit mode", () => __awaiter(this, void 0, void 0, function* () { yield pressKey(this.getPage(), "Escape"); })); }); } } //# sourceMappingURL=TextArea.js.map