Maximize and Full screen Window using manage() method in Selenium WebDriver

manage() method is very basic and we are using it very frequently in selenium WebDriver tests. 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 but here we will discuss about how to maximize browser or set it to full screen mode.

How to Maximize and Full screen Window?
package TestPack;

import org.openqa.selenium.WebDriver;

public class testManage {

 public static void main(String[] args) {
  String exePath = "D:\\chromedriver_win32\\chromedriver.exe";
  System.setProperty("", exePath);
  WebDriver driver = new ChromeDriver();  
  //To maximize the size of window.
  //To set browser is full screen mode.

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

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

No comments:

Post a comment