Selenium maximize window using manage() method in Selenium WebDriver

manage() method is very basic which we are using to maximize window in selenium very frequently. You can use it to manage size and positions of browser window during your test. You can use it to add or delete cookie, get cookie, timeouts, waits and there are many other usages as well. we need to use Selenium maximize window in almost every test script.

Command syntax for Window Maximize in Selenium

It is very simple and basic command using which you can maximize browser window in selenium test. driver.manage().window().maximize(); syntax will maximize browser window in selenium test.

Command syntax for selenium full screen

You can use driver.manage().window().fullscreen(); syntax to full screen window in selenium test.

Below given example will show you how to driver maximize selenium works to maximize chrome browser window in selenium and how selenium webdriver fullscreen will work for selenium open browser in full screen.

Selenium Maximize Window and Full screen Window example

package TestPack;

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

public class testManage {

 public static void main(String[] args) {
  String exePath = "D:\\chromedriver_win32\\chromedriver.exe";
  System.setProperty("webdriver.chrome.driver", exePath);
  WebDriver driver = new ChromeDriver();  
  
  driver.get("http://only-testing-blog.blogspot.com/2015/01/iframe1.html");
  
  //To maximize browser in selenium.
  driver.manage().window().maximize();
  
  //To set browser is full screen in selenium.
  driver.manage().window().fullscreen();
 }
}

Do you know Usage of navigate() method in Selenium WebDriver?

In above example, manage().window().maximize() will set window in maximized position in selenium test and manage().window().fullscreen() will set window in full screen mode in selenium test.

No comments:

Post a Comment