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();
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;
import org.openqa.selenium.chrome.ChromeDriver;
public class maximizewindowExample {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
//Minimize the browser window.
driver.manage().window().minimize();
driver.navigate().to("http://only-testing-blog.blogspot.com/2013/09/testing.html");
driver.findElement(By.xpath("//span[normalize-space()='Test Link']")).click();
driver.manage().window().maximize();
}
}
In above given example, minimize() method will minimize the chrome browser window.
No comments:
Post a Comment