I am relatively new to Puppeteer, so bear with me if it’s a beginner’s mistake.
Puppeteer versions tested: 6.0.0 / 9.0.0 / 10.0.0
When I take a screenshot using Puppeteer in headless: false mode, the viewport shrinks for a moment (seems to become almost half the size) right when the screenshot is being captured, then goes back to full size until the next screenshot.
I’ve read that setting captureBeyondViewport: false should fix this issue, but the flickering persists across all versions I’ve tried. Am I missing something here?
The flickering could be due to the dynamic content or other resources that are still loading when you take the screenshot. One trick you can try is to ensure the page is fully loaded using page.evaluate() method before taking the screenshot.
Try this snippet just before your page.screenshot() call:
It’s interesting that headless: false mode is giving you this flickering issue during screenshots. One possible solution to explore is incorporating a slight delay before taking the screenshot, which could stabilize the viewport. You can try adding await page.waitForTimeout(1000); immediately before the page.screenshot() call to see if it alleviates the flickering. Another approach might involve testing with fullPage: true, which some users have found reduces visual anomalies. Experimenting with these suggestions could help you troubleshoot the flickering problem effectively.