UNPKG

playwright-fluent

Version:
38 lines (37 loc) 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.clickOnHandle = exports.defaultClickOptions = void 0; const hover_on_handle_1 = require("../hover-on-handle"); const utils_1 = require("../../../utils"); const is_handle_enabled_1 = require("../is-handle-enabled"); exports.defaultClickOptions = { button: 'left', clickCount: 1, delay: 100, stabilityInMilliseconds: 300, timeoutInMilliseconds: 30000, verbose: false, }; async function clickOnHandle(selector, name, page, options) { if (!page) { throw new Error(`Cannot click on '${name}' because no browser has been launched`); } if (!selector) { throw new Error(`Cannot click on '${name}' because selector was not found in DOM`); } const hoverOptions = { ...hover_on_handle_1.defaultHoverOptions, verbose: options.verbose, stabilityInMilliseconds: options.stabilityInMilliseconds, timeoutInMilliseconds: options.timeoutInMilliseconds, }; await (0, hover_on_handle_1.hoverOnHandle)(selector, name, page, hoverOptions); (0, utils_1.report)('waiting for the selector to be enabled ...', options.verbose); await (0, utils_1.waitUntil)(() => (0, is_handle_enabled_1.isHandleEnabled)(selector, { verbose: false }), `Cannot click on '${name}' because this selector is disabled`, { ...options, throwOnTimeout: true, wrapPredicateExecutionInsideTryCatch: true, }); await selector.click(options); } exports.clickOnHandle = clickOnHandle;