@progress/kendo-e2e
Version:
Kendo UI end-to-end test utilities.
46 lines • 1.67 kB
JavaScript
/*
* These functions are executed in the browser by invoking `driver.executeScript`
* which converts them to strings first.
*
* Use only supported browser APIs when authoring them.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.hideElements = hideElements;
exports.restoreElements = restoreElements;
exports.setViewport = setViewport;
function hideElements(selectors) {
for (const selector of selectors !== null && selectors !== void 0 ? selectors : []) {
const el = document.querySelector(selector);
if (el) {
el.setAttribute('data-display', el.style.display);
el.style.display = 'none';
}
}
}
function restoreElements(selectors) {
for (const selector of selectors !== null && selectors !== void 0 ? selectors : []) {
const el = document.querySelector(selector);
if (el) {
el.style.display = el.getAttribute('data-display');
el.removeAttribute('data-display');
}
}
}
function setViewport(selector, offsetY) {
const element = document.querySelector(selector);
const root = document.documentElement;
const rect = element.getBoundingClientRect();
let top = rect.top + offsetY;
const maxScrollTop = root.scrollHeight - root.clientHeight;
if (top < 0) {
top = 0; // Prevent negative top values
}
if (root.clientHeight < rect.bottom + offsetY) {
const scrollTop = Math.min(top, maxScrollTop);
root.scrollTop = scrollTop;
top = top - scrollTop;
}
return new DOMRect(rect.x, top, rect.width, rect.height);
}
//# sourceMappingURL=scripts.js.map
;