Fix the intermittent failures with PageOpen/PageClose test
This commit is contained in:
parent
6115a328ea
commit
66b1a1f34b
@ -816,7 +816,7 @@ describe("Interaction", () => {
|
|||||||
"window.PDFViewerApplication.scriptingReady === true"
|
"window.PDFViewerApplication.scriptingReady === true"
|
||||||
);
|
);
|
||||||
|
|
||||||
await scrollIntoView(page, getSelector("171R"));
|
await scrollIntoView(page, getSelector("138R"));
|
||||||
|
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
for (const [id, val] of [
|
for (const [id, val] of [
|
||||||
|
@ -255,23 +255,12 @@ async function scrollIntoView(page, selector) {
|
|||||||
await page.evaluate(sel => {
|
await page.evaluate(sel => {
|
||||||
const element = document.querySelector(sel);
|
const element = document.querySelector(sel);
|
||||||
element.scrollIntoView({ behavior: "instant", block: "start" });
|
element.scrollIntoView({ behavior: "instant", block: "start" });
|
||||||
|
return new Promise(resolve => {
|
||||||
|
document
|
||||||
|
.getElementById("viewerContainer")
|
||||||
|
.addEventListener("scrollend", resolve, { once: true });
|
||||||
|
});
|
||||||
}, selector);
|
}, selector);
|
||||||
await page.waitForFunction(
|
|
||||||
sel => {
|
|
||||||
const toolbarHeight = document
|
|
||||||
.querySelector("#toolbarContainer")
|
|
||||||
.getBoundingClientRect().height;
|
|
||||||
const element = document.querySelector(sel);
|
|
||||||
const { top, bottom } = element.getBoundingClientRect();
|
|
||||||
return (
|
|
||||||
Math.abs(top) < toolbarHeight + 100 ||
|
|
||||||
Math.abs(bottom - window.innerHeight) < 100 ||
|
|
||||||
(top > toolbarHeight && bottom < window.innerHeight)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
{},
|
|
||||||
selector
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function hover(page, selector) {
|
async function hover(page, selector) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user