Saturday, March 3, 2018

How to maximize the browser window in Selenium WebDriver

In this post, we will discuss How to maximize the browser window in Selenium WebDriver. When we launch a browser using Selenium WebDriver, by default it is not in its maximized state. Here, we will see how to maximize a browser using automation script.

NOTE : It is a good practice to maximize a browser after launch.

Code Snippet to maximize the browser window :
//Maximize the Browser

How to maximize the browser window in Selenium WebDriver, Maximize Window Using Selenium WebDriver, Maximizing the browser window,Failed to maximize browser using window().maximize()

Maxmize a browser

Lets see the complete example to set the browser in maximize mode just after launch.
package demoPackage;

import org.openqa.selenium.WebDriver;

public class SeleniumDemo {

 public static WebDriver driver;
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  System.out.println("Launching the chrome driver  ");
  // Set the chrome driver exe file path
  // Instantiate the chrome driver
  driver = new ChromeDriver();
  // set the browser URL in get() to load the webpage
  //Maximize the Browser



This is all about Maximizing the browser windowHope you like this simple example. Thank you for reading this article, and if you have any problem, have a another better useful solution about this article, please write message in the comment section.

No comments:

Post a Comment