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

  • Best Practice for Cloud

    const browser = await playwright.chromium.launch();
    
    const context = await browser.newContext({
      viewport: {
        width: 1920,
        height: 1080
      }
    });
    

    This works reliably across all cloud environments.

    Reference:

    Playwright - Javascript - Maximize Browser