Apify

Apify and Crawlee Official Forum

b
F
A
J
A

How to resize Playwright browser window?

There is the method page.setViewportSize() (https://playwright.dev/docs/api/class-page#page-set-viewport-size)
to resize Playwright browser window.

With Crawlee/PlaywrightCrawler, How can I set the size of browser window ?

const crawler = new PlaywrightCrawler({ // Stop crawling after 5 pages maxRequestsPerCrawl: 5, // https://crawlee.dev/api/playwright-crawler/interface/PlaywrightLaunchContext launchContext: { // https://crawlee.dev/api/playwright-crawler/interface/PlaywrightLaunchContext#launchOptions launchOptions: { stealth: true, headless: false, }, ????? }, .....
L
1 comment
You can pass any Playwright params to the launchOptions so this should work:

Plain Text
launchOptions: {
   stealth: true,
   headless: false,
   viewport: {
      width,
      height,
   }      
}


But you can also use page.setViewportSize() in preNavigationHooks
https://crawlee.dev/api/puppeteer-crawler/interface/PuppeteerCrawlerOptions#preNavigationHooks
Add a reply
Sign up and join the conversation on Discord
Join