Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set max viewport in Puppeteer?

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?

like image 318
fehif Avatar asked Sep 28 '18 10:09

fehif


People also ask

How do you set a puppeteer viewport?

To set max viewport in Puppeteer, we set the defaultViewport option to null . const browser = await puppeteer. launch({ defaultViewport: null });

Does puppeteer need Chrome installed?

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.


1 Answers

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.

like image 151
n00b_g33k Avatar answered Sep 20 '22 08:09

n00b_g33k