SUBSCRIBE HERE TO GET POST UPDATES VIA EMAIL :

Delivered by FeedBurner

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;
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 the size of window.
  driver.manage().window().maximize();
  
  //To set browser is full screen mode.
  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 and manage().window().fullscreen() will set window in full screen mode.

No comments:

Post a comment