When I run a new page, I must specify size of the viewport using the setViewport
function:
await page.setViewport({ width: 1920, height: 1080 })
I want use max viewport.
How can I make the viewport resizable according to the window size?
To set max viewport in Puppeteer, we set the defaultViewport option to null . const browser = await puppeteer. launch({ defaultViewport: null });
By default, Puppeteer downloads and uses a specific version of Chromium so its API is guaranteed to work out of the box. To use Puppeteer with a different version of Chrome or Chromium, pass in the executable's path when creating a Browser instance: const browser = await puppeteer.
I may be very late on this. Nevertheless for others, try:
const browser = await puppeteer.launch({defaultViewport: null});
Set the defaultViewport
option to null
as above to disable the 800x600 resolution. It takes the max resolution then.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With