UNPKG

@vibe/testkit

Version:
68 lines 2.87 kB
"use strict"; 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.RadioButton = void 0; const test_1 = require("@playwright/test"); const BaseElement_1 = require("./BaseElement"); /** * Class representing a RadioButton element. * Extends the BaseElement class. */ class RadioButton extends BaseElement_1.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_1.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_1.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_1.test.step(`Check if radio button is checked for ${this.getElementReportName()}`, () => __awaiter(this, void 0, void 0, function* () { return yield this.getLocator().isChecked(); })); }); } } exports.RadioButton = RadioButton; //# sourceMappingURL=RadioButton.js.map