Skip to main content
Experience faster, smarter testing with BrowserStack AI Agents. See what your workflow’s been missing. Explore now!
No Result Found

Change browser window size

Learn how to resize browser window during an Automate session.

You can use Selenium commands to resize browser windows in an Automate session. This guide will help you:

  1. Maximize browser window during test runtime
  2. Resize browser window during test runtime

Maximizing browser window size

In any Selenium test - whether run locally or on a Selenium Grid—the browser window is not maximized upon launch. This can keep you from viewing all the elements of the web application you’re testing.

You can programmatically maximize the browser window by adding a Selenium command to your test script.

Supported Browsers and Operating Systems

Capability Description
Supported OS All desktop OS (not supported on mobile devices)
Supported Browser Chrome

If you are using BrowserStack SDK, you can set the following capabilities in the browserstack.yml file:

browserstack.yml
chromeOptions: 
      args:                      
        - --start-maximized

Resizing the browser window

You might have some test scenarios which require you to resize the browser window. To execute this step, you can add a Selenium command to your test script.

Supported Browsers and Operating Systems

Capability Description
Supported OS All desktop OS (not supported on mobile devices)
Supported Browser All (Chrome, Safari, Firefox, IE, Edge) except Safari 10.1

If the browser window is larger than the display screen resolution, elements will appear off-screen. Learn how to change the desktop screen resolution.

The following sample shows you how to resize the browser window to custom dimensions using Selenium:

browserstack.yml
resolution: 1024x768

Exceptions

Safari 10.1 has a known bug where maximizing or resizing the browser window doesn’t work as expected. Refer to StackOverflow and GitHub pages for more information.

This behavior occurs whether the test is run locally on the workstation or on a Selenium Grid. There’s no workaround for this bug at the moment.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle