How to set max viewport in Puppeteer?

fehif picture fehif · Sep 28, 2018 · Viewed 37.9k times · Source

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?

Answer

n00b_g33k picture n00b_g33k · Mar 22, 2019

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.