Selenium Minimize Window Of Browser

Minimize window in selenium 

Selenium 4 has built in method to minimize the browser window. It is less used method in selenium but still you can use it if you want to minimize window in between selenium test. minimize() method will perform browser minimize user action. You can run your selenium tests in minimized browser mode and you can perform your other tasks beside.

  • minimize() method is part of WebDriver.Window method.
  • This method will return nothing because it's return type is void.
  • It will minimize the current working window if it is not already minimized.
  • It is helpful when your are performing manual testing or any other work as your selenium tests will be executed in minimized mode.
  • Syntax : driver.manage().window().maximize();

Selenium Minimize Window using minimize() method

Let us see practical example of using minimize() method in selenium.

Selenium minimize() method example

package testPackage;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

public class maximizewindowExample {

	public static void main(String[] args) {
		System.setProperty("", "D:\\chromedriver.exe");
		WebDriver driver=new ChromeDriver();
		//Minimize the browser window.		
		driver.findElement(By.xpath("//span[normalize-space()='Test Link']")).click();

In above given example, minimize() method will minimize the chrome browser window.

No comments:

Post a Comment