---
title: Change browser window size with Selenium
description: Learn how to resize or maximize a browser window during Selenium test
  sessions. Covers Maximize a window and Resize a window.
source_url:
  html: https://testingbot.com/support/web-automate/selenium/browser-window-size
  md: https://testingbot.com/support/web-automate/selenium/browser-window-size.md
---

# 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](https://testingbot.com#maximize)
- [Resize a window](https://testingbot.com#resize)

## Maximize a window

The example below shows how to maximize the window to the full screen resolution (you can [change the screen resolution](https://testingbot.com/support/web-automate/selenium/change-screen-resolution) as well).

[Java](https://testingbot.com#) [Python](https://testingbot.com#) [NodeJS](https://testingbot.com#) [Ruby](https://testingbot.com#) [PHP](https://testingbot.com#) [C#](https://testingbot.com#)

```java
driver.manage().window().maximize();
```

```python
driver.maximize_window()
```

```javascript
await driver.manage().window().maximize();
```

```ruby
driver.manage.window.maximize
```

```php
$web_driver->manage()->window()->maximize();
```

```csharp
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](https://testingbot.com/support/web-automate/selenium/change-screen-resolution).

[Java](https://testingbot.com#) [Python](https://testingbot.com#) [NodeJS](https://testingbot.com#) [Ruby](https://testingbot.com#) [PHP](https://testingbot.com#) [C#](https://testingbot.com#)

```java
Dimension dimension = new Dimension(1920, 1080);
driver.manage().window().setSize(dimension);
```

```python
driver.set_window_size(1920, 1080)
```

```javascript
await driver.manage().window().setRect({ width: 1920, height: 1080 });
```

```ruby
driver.manage.window.resize_to(1920, 1080)
```

```php
$web_driver->manage()->window()->setSize(new WebDriverDimension(1920, 1080));
```

```csharp
driver.Manage().Window.Size = new Size(1920, 1080);
```

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

### Looking for more help?

Have questions or need more information? Reach out via email or Slack.

[Email us](https://testingbot.com/contact/new) [Join our Slack](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
