javascriptviewportplaywrightsaucelabslambdatest

How to maximize the Window size in Playwright?


I'm running my Playwright test scenarios and facing an issue while trying to run scenarios with windows “maximized” / full window.

I set viewport as null for browser context, and it works in maximized view on local, but on remote-cloud-providers like LambdaTest/SauceLabs it works only with reduced size.

I tried with view port it does not work: https://playwright.dev/docs/api/class-browser/#browser-new-context-option-viewport.


Solution

  • You can pass arguments like below during browser launch:

      const browser=  await chromium.launch({ headless: false,
                args:['--window-size=1920,1040']})
      const context= await browser.newContext()
      const page = await context.newPage()
    

    Reference:

    Playwright - Javascript - Maximize Browser