How to Maximize Window in Selenium [Chrome Browser Window]?

How to Solve the Chrome Browser Maximize Issue?

In this post of softwaretestingo blogs, we are going to discuss more in detail about, how you can solve the maximize issue when you are trying to open the Chrome browser using the selenium webDriver. But when you try to open the chrome browser you are maybe getting a WebDriverException but if you go through with your code then you are finding any issue on your code.

Let me told you one simple reason for getting this is you may be using an old version of chrome driver. so you need to download the latest chrome driver from the seleniumHQ website or you can use this link to download the latest chrome driver.

Chome WebDriverException:
package com.selenium;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Maximize_Chrome_Browser 
{
   static
   {
   //set the path of driver executable
   String value=("D:\\Git_Prgms\\softwaretestingblog\\Latest_Env_Jars\\Drivers\\chromedriver.exe");
   System.setProperty("webdriver.chrome.driver", value);
   }
   public static void main(String[] args) throws InterruptedException {
   WebDriver driver=new ChromeDriver();
   driver.get("https://www.google.com");
   driver.manage().window().maximize();
   }

}

How to maximize the window in selenium?

As we know that to maximize the browser window we have used the maximize() method but still, you can see that your window is not maximized, we are getting a WebDriverException for that.

As you see the above code there is nothing wrong with the code but when we try to execute the code we are getting an exception and the browser is not maximized.  The Above Code is run in an environment

Selenium Version: Selenium 3.7.1
Chrome Driver Version: ChromeDriver v2.25
Chrome Browser Version: Version 62.0.3202.89

We are getting this exception

Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension from unknown error: page could not be found:

Chrome Brrowser

Note: This Exception comes because of the lower version of Chromedriver, so to fix this we need to update the Chromedriver. so I have updated with the latest Chromedriver that is ChromeDriver 2.33

After Update Here Is The Result:

Chrome Brrowser sucess

I hope this above article about fixing the chrome browser maximize issue can resolve your problem. for more selenium java programs and selenium interview questions, you visit our blog or you can get all updates about our blog by joining of SoftwareTestingo Telegram Group.

I love open-source technologies and am very passionate about software development. I like to share my knowledge with others, especially on technology that's why I have given all the examples as simple as possible to understand for beginners. All the code posted on my blog is developed, compiled, and tested in my development environment. If you find any mistakes or bugs, Please drop an email to softwaretestingo.com@gmail.com, or You can join me on Linkedin.

2 thoughts on “How to Maximize Window in Selenium [Chrome Browser Window]?”

Leave a Comment