Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Headful Puppeteer - Screenshot reloads the page

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?

like image 492
Silas Avatar asked Dec 30 '25 13:12

Silas


1 Answers

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});
like image 86
Julio Codesal Avatar answered Jan 01 '26 05:01

Julio Codesal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!