---
description: In this tutorial, you will learn how to maximize, minimize or resize the browser using selenium Webdriver. Explained through different scenarios using maximize() method and dimensions for resizing the
title: How to Maximize Browser Window in Selenium
image: https://www.guru99.com/images/1/011019_1056_MaximizeBro1.png
---

 

[Skip to content](#main) 

## Maximize Browser in Selenium

In this tutorial, you will learn how to maximize, minimize or resize the browser using selenium Webdriver. Explained through different scenarios using maximize() method and dimensions for resizing the browser.

## Why Maximize a Browser in Selenium Automation?

Elements on the web application may not be recognized by the selenium if the browser is not maximized and thereby making framework fail. Hence, Maximize the browser is very important part of selenium framework. It is good practice to maximize the browser while automating any web application. When the user executes the selenium framework or any script, browser may not be in the full screen state and you need to maximize the browser using window maximize in Selenium to view all the elements of the web application. It is good to maximize the browser at the start of the script, so that the script gets executed successfully without any error.

## Steps to Maximize Window in Selenium

Here is how to maximize browser in Selenium:

To maximize browser in Selenium, you need to call the maximize() Selenium command to maximize window interface of the driver class.

void maximize() – This method is used to maximize the current browser.

[](https://www.guru99.com/images/1/011019%5F1056%5FMaximizeBro1.png)

Maximize the Browser in Selenium

You can customize the size of the browser according to the requirement of the scenario. Selenium webdriver does not provide any method for minimizing the browser, there is no such direct method. You need to use resize method to minimize the browser.

void setSize() – This method is used to set the size of the current browser.

Dimension getSize() – This method is used to get the size of the browser in height and width. It returns the dimension of the browser.

Point setPosition() – This method is used to set the position of the current browser.

## How to Maximize a Browser window using Webdriver

### a) Selenium script with explanation.

**Script Description :** In the below maximize in Selenium script shown, the maximization of the browser using [testNG framework](https://www.guru99.com/all-about-testng-and-selenium.html), steps of the scenario for maximize window Selenium are :

1. Open the chrome browser .
2. Launch the site .
3. Wait for a few seconds as to view the browser maximize in Selenium action .
4. Close the browser.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Maximize {

	public static void main(String args[]) throws InterruptedException
	{
		WebDriver driver;
		
		System.setProperty("webdriver.chrome.driver","E://Selenium//Selenium_Jars//chromedriver.exe");
		 driver= new ChromeDriver();
 		 
         // Launch the application
     	 driver.get("https://www.guru99.com/");
     	 
     	     	//Resize current window to the set dimension
     	        driver.manage().window().maximize();
     	       
     	       //To Delay execution for 10 sec. as to view the maximize browser
     	        Thread.sleep(10000);
     	       
     	        //Close the browser
     	        driver.quit();
	}	
}

#### b) Output Analysis

Opened the chrome browser , maximized the browser, wait for a few seconds and closed the browser.

### RELATED ARTICLES

* [CSS Selector in Selenium ](https://www.guru99.com/locators-in-selenium-ide.html "CSS Selector in Selenium")
* [Selenium Grid Tutorial: Setup a Hub and Node ](https://www.guru99.com/introduction-to-selenium-grid.html "Selenium Grid Tutorial: Setup a Hub and Node")
* [How to Read/Write Data from Excel File: Selenium POI ](https://www.guru99.com/all-about-excel-in-selenium-poi-jxl.html "How to Read/Write Data from Excel File: Selenium POI")
* [How to Drag and Drop in Selenium (Example) ](https://www.guru99.com/drag-drop-selenium.html "How to Drag and Drop in Selenium (Example)")

## How to Resize a Browser using selenium Webdriver

### a) Selenium script with explanation.

**Script Description :** In the below Selenium script shown the resize of the browser using testNG framework , steps of the scenario are :

1. Open the chrome browser .
2. Launch the site .
3. Wait for a few seconds as to view the resize action .
4. Close the browser.

import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Resize {

	public static void main(String args[]) throws InterruptedException
	{
		WebDriver driver;
	
		System.setProperty("webdriver.chrome.driver","E://Selenium//Selenium_Jars//chromedriver.exe");
		 driver= new ChromeDriver();
 		 
         // Launch the application
     	 driver.get("https://www.guru99.com/");
     	 
     	Dimension d = new Dimension(300,1080);
     	//Resize current window to the set dimension
     	   driver.manage().window().setSize(d);
     	        
     	 //To Delay execution for 10 sec. as to view the resize browser
     	 Thread.sleep(10000);
     	       
     	 //Close the browser
     	 driver.quit();
	}	
}

#### b) Output Analysis

Opened the chrome browser , resized the browser, wait for a few seconds and closed the browser.

## How to Minimize a Browser window using Webdriver.

### a) Selenium script with explanation.

**Script Description :** In the below Selenium script shown the minimize of the browser using testNG framework , steps of the scenario are :

1. Open the chrome browser .
2. Launch the site .
3. Wait for a few seconds as to view the minimize action .
4. Close the browser.

import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Minimize {

	public static void main(String args[]) throws InterruptedException
	{
		WebDriver driver;
	
		System.setProperty("webdriver.chrome.driver","E://Selenium//Selenium_Jars//chromedriver.exe");
		 driver= new ChromeDriver();
 		 
         // Launch the application
     	 driver.get("https://www.guru99.com/");
     	 
     	Point p = new Point(0,3000);
     	
     	//Minimize the current window to the set position
     	        driver.manage().window().setPosition(p);
     	        
     	       //To Delay execution for 10 sec. as to view the minimize browser
     	        //you can view in the taskbar below of the screen.
     	        Thread.sleep(10000);
     	        
     	        //Close the browser
     	        driver.quit();
	}	
}

**Note:** If the user wants to use Firefox browser, then user needs to set property of FirefoxDriver and create FirefoxDriver object instead of ChromeDriver in all above 3 scenarios scripts as given below:

System.setProperty("webdriver.gecko.driver","E://Selenium//Selenium_Jars//geckodriver.exe ");
 driver= new FirefoxDriver();

#### b) Output Analysis

Opened the chrome browser , minimized the browser, wait for a few seconds and closed the browser.

## TroubleShooting

* Use the latest versions of Selenium Jars, chromedriver, marionette driver and IEdriver etc.
* Check the compatibility of the selenium jars and browser used.

## Summary

* In the above tutorial, we illustrate the resizing of the browser through different scenarios like to maximize, minimize and resize as required in the project framework for different functionality.
* In the first scenario, we have shown the resize of the browser in selenium.  
Dimension d = new Dimension(300,1080);  
driver.manage().window().setSize(d);
* In the second scenario, we have shown the Selenium maximize window of the browser.  
driver.manage().window().maximize();
* In the third scenario, we have shown the minimize of the browser in selenium.  
Point p = new Point(0,3000);  
driver.manage().window().setPosition(p);

#### Summarize this post with:

ChatGPT Perplexity Grok Google AI 

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.** 

##### Sign up for the newsletter

Subscribe for Free 

You have successfully subscribed.  
Please check your inbox. 

![AI-Newsletter]() Chosen by over **350,000+** professionals 

[Scroll to top ](#wrapper)Scroll to top 

× 

Toggle Menu Close 

Search for: 

Search

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/maximize-resize-minimize-browser.png","url":"https://www.guru99.com/images/maximize-resize-minimize-browser.png","width":"282","height":"150","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/maximize-resize-minimize-browser-selenium.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/selenium","name":"Selenium"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/maximize-resize-minimize-browser-selenium.html","name":"How to Maximize Browser Window in Selenium"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/maximize-resize-minimize-browser-selenium.html#webpage","url":"https://www.guru99.com/maximize-resize-minimize-browser-selenium.html","name":"How to Maximize Browser Window in Selenium","dateModified":"2024-01-02T16:17:15+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/maximize-resize-minimize-browser.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/maximize-resize-minimize-browser-selenium.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/admin","name":"Krishna Rungta","url":"https://www.guru99.com/author/admin","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/krishna-rungta-v2-120x120.png","url":"https://www.guru99.com/images/krishna-rungta-v2-120x120.png","caption":"Krishna Rungta","inLanguage":"en-US"},"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"Selenium","headline":"How to Maximize Browser Window in Selenium","description":"In this tutorial, you will learn how to maximize, minimize or resize the browser using selenium Webdriver. Explained through different scenarios using maximize() method and dimensions for resizing the","keywords":"selenium","@type":"Article","author":{"@id":"https://www.guru99.com/author/admin","name":"Krishna Rungta"},"dateModified":"2024-01-02T16:17:15+05:30","image":{"@id":"https://www.guru99.com/images/maximize-resize-minimize-browser.png"},"copyrightYear":"2024","name":"How to Maximize Browser Window in Selenium","subjectOf":[{"@type":"HowTo","name":"How to Maximize Window in Selenium:","description":"Here is a step-by-step process on How to Maximize Window in Selenium:","step":[{"@type":"HowToStep","name":"Step 1) Open browser.","text":"Open the chrome browser.","image":"https://www.guru99.com/images/1/011019_1056_MaximizeBro1.png","url":"https://www.guru99.com/maximize-resize-minimize-browser-selenium.html#step1"},{"@type":"HowToStep","name":"Step 2) Site URL","text":"Launch the site URL","url":"https://www.guru99.com/maximize-resize-minimize-browser-selenium.html#step2"},{"@type":"HowToStep","name":"Step 3) View action","text":"Wait for a few seconds as to view the minimize action.","url":"https://www.guru99.com/maximize-resize-minimize-browser-selenium.html#step3"},{"@type":"HowToStep","name":"Step 4) Termination.","text":"Close the browser","url":"https://www.guru99.com/maximize-resize-minimize-browser-selenium.html#step4"}]}],"@id":"https://www.guru99.com/maximize-resize-minimize-browser-selenium.html#schema-266886","isPartOf":{"@id":"https://www.guru99.com/maximize-resize-minimize-browser-selenium.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/maximize-resize-minimize-browser-selenium.html#webpage"}}]}
```
