playwright-fluent
Version:
Fluent API around playwright
29 lines (28 loc) • 1.12 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.isHandleNotVisible = void 0;
const utils_1 = require("../../../utils");
const get_intersection_ratio_of_handle_1 = require("../get-intersection-ratio-of-handle");
async function isHandleNotVisible(selector, options) {
if (selector === undefined || selector === null) {
return true;
}
const visibleRatio = await (0, get_intersection_ratio_of_handle_1.getIntersectionRatioOfHandle)(selector);
(0, utils_1.report)(`visible ratio is ${visibleRatio}`, options.verbose);
if (visibleRatio <= 0) {
(0, utils_1.report)(`selector is not visible in the current viewport`, options.verbose);
return true;
}
const result = await selector.evaluate((el) => {
const style = window.getComputedStyle(el);
if (style && style.opacity && style.opacity === '0') {
return true;
}
if (style && style.visibility === 'hidden') {
return true;
}
return false;
});
return result;
}
exports.isHandleNotVisible = isHandleNotVisible;
;