Features

Maximize or resize browser window

Selenium WebDriver makes it possible to resize and maximize a browser window during an automated test.
Below you'll find examples on how to:

Maximize a window

The example below shows how to maximize the window to the full screen resolution (you can change the screen resolution as well).

Copy code
driver.manage.window.maximize
Copy code
driver.manage().window().maximize();
Copy code
$web_driver->manage()->window()->maximize();
Copy code
driver.maximize_window()
Copy code
driver.manage().window().maximize();
Copy code
driver.Manage().Window.Maximize();

Maximizing a window will only work on desktop browsers, not on mobile.

Resize a window

The example below shows how to resize the current window. If you specify a size larger than the current resolution, elements may appear off-screen.
Find out how to change the screen resolution.

Copy code
driver.manage.window.resize_to(1920, 1080)
Copy code
Dimension dimension = new Dimension(1920, 1080);
driver.manage().window().setSize(dimension);
Copy code
$web_driver->manage()->window()->setSize(new WebDriverDimension(1920, 1080));
Copy code
driver.set_window_size(1920, 1080)
Copy code
driver.manage().window().setSize(1920, 1080);
Copy code
driver.Manage().Window.Size = new Size(1920, 1080);

Resizing a window will only work on desktop browsers, not on mobile.