UNPKG

playwright-fluent

Version:
37 lines (36 loc) 1.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.uncheckHandle = 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"); const is_handle_checked_1 = require("../is-handle-checked"); async function uncheckHandle(selector, name, page, options) { if (!page) { throw new Error(`Cannot uncheck '${name}' because no browser has been launched`); } if (!selector) { throw new Error(`Cannot uncheck '${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)('Checking if selector is already unchecked ...', options.verbose); const isChecked = await (0, is_handle_checked_1.isHandleChecked)(selector, { verbose: options.verbose }); if (!isChecked) { (0, utils_1.report)('Selector is already unchecked: nothing to do.', options.verbose); return; } (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 uncheck '${name}' because this selector is disabled`, { ...options, throwOnTimeout: true, wrapPredicateExecutionInsideTryCatch: true, }); await selector.uncheck(); } exports.uncheckHandle = uncheckHandle;