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 configutation file:
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
BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.
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
All (Chrome, Safari, Firefox, IE, Edge) except Safari 10.1
The following sample shows you how to maximize a 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
/* Requires Java Library
You need to import the library org.openqa.selenium.Dimension into your Java project before implementing the resize action in your script. */Dimensiondimension=newDimension(1920,1080);driver.manage().window().setSize(dimension);
driver.manage.window.resize_to(1920,1080)
driver.Manage().Window.Size=newSize(x,y);
driver.set_window_size(width,height)
driver.manage().window().setSize(x,y);
/* Requires PHP Class
You need to use the class "Facebook\WebDriver\WebDriverDimension" into your PHP test before implementing the resize action in your code. */$web_driver->manage()->window()->setSize(newWebDriverDimension(1920,1080));
$driver->set_window_size(1920,1080);
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.
Did this page help you?
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