UNPKG

@vibe/testkit

Version:
58 lines 2.57 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 { TextField } from "./TextField"; /** * Class representing a TextArea element. * Extends the BaseElement class. */ export class TextArea extends BaseElement { /** * Create a TextArea. * @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.textAreaWrapper = new Button(this.page, this.locator, "Text Area Wrapper"); this.textAreaInput = new TextField(this.page, this.locator.locator("textarea"), "Text Area Input"); } /** * 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.step(`Set text in TextArea: ${text}`, () => __awaiter(this, void 0, void 0, function* () { yield this.textAreaWrapper.click(); yield this.textAreaInput.waitFor(); yield this.textAreaInput.setText(text); yield this.exitEditMode(); })); }); } /** * 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.page, "Escape"); })); }); } } //# sourceMappingURL=TextArea.js.map