Skip to content

Commit 9b39365

Browse files
committed
test(android): wait for content to render before swiping
CI showed the swipe assertion timing out with scrollY stuck at 0 on every retry, even though the swipe call itself completed without error. androidDevice.input.swipe() injects a raw touch event through the OS input pipeline, independent of the CDP channel used by setContent(), so the gesture can land before the new content is actually composited and presented on the device screen. Wait for two animation frames after setContent() so the swipe reliably hits the rendered page.
1 parent c658786 commit 9b39365

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎tests/android/input.spec.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ test('androidInput.swipe should start from the given point', async ({ androidDev
2020
const context = await androidDevice.launchBrowser();
2121
const [page] = context.pages();
2222
await page.setContent(`<div style="height: 3000px">${'line<br>'.repeat(200)}</div>`);
23+
// androidDevice.input.swipe() injects a raw touch event straight into the OS input
24+
// pipeline, independent of the CDP connection used by setContent() above. Wait for
25+
// the new content to actually be composited and presented on the device screen,
26+
// otherwise the swipe can land on the previous (blank) frame and never scroll anything.
27+
await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))));
2328
await androidDevice.input.swipe({ x: 250, y: 1500 }, [{ x: 250, y: 500 }], 30);
2429
await expect.poll(() => page.evaluate(() => window.scrollY)).toBeGreaterThan(0);
2530
await context.close();

0 commit comments

Comments
 (0)