2

I'm using Puppeteer to take full size screenshots in headful mode, as I need to interact with the browser most of the time. It runs perfectly but I noticed something odd: when the screenshot is called, it reloads the page so what I get on the capture is not always what I see in the browser.

For instance let's take this URL. If I want to display the Eiffel tower, I need to click on the slide show. No problem so far. But as soon as the screenshot is taken, the page is refreshed and goes back to the initial picture with the woman in the sofa... I have no idea what causes this behaviour.

This is my code:

const puppeteer = require('puppeteer');
args=['--window-size=1920,1080'];
const browser=await puppeteer.launch({ headless: false, defaultViewport: null, args);
const page=(await browser.pages())[0];
await page.goto('https://url.com');
await page.waitForTimeout(10000); // 10 sec timeframe to allow navigation
await page.screenshot({path: 'test.png', quality: 100, fullPage: true});
await browser.close();

I run the last version of Puppeteer (13.1.1) on a Debian 10 Linux server. Tested a lot of combinations, different arguments, timers, resolutions, etc. to no avail. Any suggestions?

1 Answer 1

7

I think it have to be with the renderization of the full page. running on windows your code I have the same behavior.

It stop to happen with this change:

await page.screenshot({path: 'test.png', captureBeyondViewport: false});
4
  • Thanks, I didn't know about this option. However it doesn't change anything for me. But from what I see I'm not the only one to have this particular issue.
    – Silas
    Jan 24, 2022 at 15:37
  • This worked for me. I have fullPage: true and captureBeyondViewport: false and it doesn't flicker and resize before the screenshot Feb 26, 2022 at 16:47
  • I had this same issue when setting a default viewport size and then screenshotting an element (not full page) that had a scrollable area. The problem was there in headless mode, too. Setting captureBeyondViewport: false fixed the issue for me completely in headless mode, and partially in non-headless (no more reload, but it shifted the viewport to a different part of the element before snapping the pic).
    – sgress454
    Jun 8, 2022 at 3:20
  • worked for me as well, doesnt flicker neither flashes Apr 26 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.