UNPKG

playwright-pom-materials

Version:

Playwright POM materials

64 lines (63 loc) 2.9 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.Clickable = void 0; const Operable_1 = require("./Operable"); class Clickable extends Operable_1.Operable { constructor(locator, options) { super(locator, options); // click this.beforeClick = options === null || options === void 0 ? void 0 : options.beforeClick; this.afterClick = options === null || options === void 0 ? void 0 : options.afterClick; this.clickAction = (options === null || options === void 0 ? void 0 : options.clickAction) || ((locator, options) => locator.click(options)); // dblclick this.beforeDblClick = options === null || options === void 0 ? void 0 : options.beforeDblClick; this.afterDblClick = options === null || options === void 0 ? void 0 : options.afterDblClick; this.dblclickAction = (options === null || options === void 0 ? void 0 : options.dblclickAction) || ((locator, options) => locator.dblclick(options)); } click(options) { return __awaiter(this, void 0, void 0, function* () { if (this.beforeClick) yield this.beforeClick(); yield this.clickAction(this.targetLocator(), options); if (this.afterClick) yield this.afterClick(); }); } dblclick(options) { return __awaiter(this, void 0, void 0, function* () { if (this.beforeDblClick) yield this.beforeDblClick(); yield this.dblclickAction(this.targetLocator(), options); if (this.afterDblClick) yield this.afterDblClick(); }); } targetLocator() { return this.locator; } waitAndClick(waitOptions) { return __awaiter(this, void 0, void 0, function* () { yield this.waitForBeingEnabled(waitOptions); yield this.click(); }); } waitAndClickWith(fn, waitOptions) { return __awaiter(this, void 0, void 0, function* () { yield this.waitForBeingEnabledWith(fn, waitOptions); yield this.click(); }); } } exports.Clickable = Clickable;