Skip to content

Commit

Permalink
fix: request an animation frame to fix flaky clickablePoint test (pup…
Browse files Browse the repository at this point in the history
…peteer#7587)

Sometimes an element has not been layed out yet and, in this case,
clickablePoint fails because backend cannot compute content quads.

Co-authored-by: Jan Scheffler <[email protected]>
  • Loading branch information
OrKoN and jschfflr authored Sep 22, 2021
1 parent df36a61 commit 7341d9f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/jshandle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ describe('JSHandle', function () {
<div style="cursor: pointer; width: 120px; height: 60px; margin: 30px; padding: 15px;"></div>
`;
});

await page.evaluate(async () => {
return new Promise((resolve) => window.requestAnimationFrame(resolve));
});
const divHandle = await page.$('div');
expect(await divHandle.clickablePoint()).toEqual({
x: 45 + 60, // margin + middle point offset
Expand All @@ -335,6 +337,9 @@ describe('JSHandle', function () {
<iframe style="border: none; margin: 0; padding: 0;" seamless sandbox srcdoc="<style>* { margin: 0; padding: 0;}</style><div style='cursor: pointer; width: 120px; height: 60px; margin: 30px; padding: 15px;' />"></iframe>
`;
});
await page.evaluate(async () => {
return new Promise((resolve) => window.requestAnimationFrame(resolve));
});
const frame = page.frames()[1];
const divHandle = await frame.$('div');
expect(await divHandle.clickablePoint()).toEqual({
Expand Down

0 comments on commit 7341d9f

Please sign in to comment.