UNPKG

@vibe/testkit

Version:
64 lines 2.7 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 { BaseElement } from "./BaseElement"; /** * Class representing a RadioButton element. * Extends the BaseElement class. */ export class RadioButton extends BaseElement { /** * Create a RadioButton element. * @param {Page} page - The Playwright page object. * @param {Locator} locator - The locator for the RadioButton element. * @param {string} elementReportName - The name for reporting purposes. */ constructor(page, locator, elementReportName) { super(page, locator, elementReportName); } /** * Check the radio button. * @returns {Promise<void>} */ select() { return __awaiter(this, void 0, void 0, function* () { yield test.step(`Check radio button for ${this.getElementReportName()}`, () => __awaiter(this, void 0, void 0, function* () { if (!(yield this.isChecked())) { yield this.getLocator().check(); } })); }); } /** * Uncheck the radio button. * @returns {Promise<void>} */ unselect() { return __awaiter(this, void 0, void 0, function* () { yield test.step(`Uncheck radio button for ${this.getElementReportName()}`, () => __awaiter(this, void 0, void 0, function* () { if (yield this.isChecked()) { yield this.getLocator().uncheck(); } })); }); } /** * Check if the radio button is checked. * @returns {Promise<boolean>} True if the radio button is checked, false otherwise. */ isChecked() { return __awaiter(this, void 0, void 0, function* () { return yield test.step(`Check if radio button is checked for ${this.getElementReportName()}`, () => __awaiter(this, void 0, void 0, function* () { return yield this.getLocator().isChecked(); })); }); } } //# sourceMappingURL=RadioButton.js.map