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, }, ????? }, .....
Page | Playwright
* extends: [EventEmitter]
1 Reply
other-emerald
other-emerald3y ago
You can pass any Playwright params to the launchOptions so this should work:
launchOptions: {
stealth: true,
headless: false,
viewport: {
width,
height,
}
}
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

Did you find this page helpful?