In this post, we will discuss How to maximize the browser window in Selenium WebDriver. When we launch a browser using Selenium WebDriver, by default it is not in its maximized state. Here, we will see how to maximize a browser using automation script.
NOTE : It is a good practice to maximize a browser after launch.
Code Snippet to maximize the browser window :
SeleniumDemo.java
This is all about Maximizing the browser window. Hope you like this simple example. Thank you for reading this article, and if you have any problem, have a another better useful solution about this article, please write message in the comment section.
NOTE : It is a good practice to maximize a browser after launch.
Code Snippet to maximize the browser window :
//Maximize the Browser driver.manage().window().maximize();
Maxmize a browser
Lets see the complete example to set the browser in maximize mode just after launch.SeleniumDemo.java
package demoPackage; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class SeleniumDemo { public static WebDriver driver; public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Launching the chrome driver "); // Set the chrome driver exe file path System.setProperty("webdriver.chrome.driver","E:\\selenium_sumit\\chromedriver_win32_2.33\\chromedriver.exe"); // Instantiate the chrome driver driver = new ChromeDriver(); // set the browser URL in get() to load the webpage driver.get("https://www.google.com"); //Maximize the Browser driver.manage().window().maximize(); } }
This is all about Maximizing the browser window. Hope you like this simple example. Thank you for reading this article, and if you have any problem, have a another better useful solution about this article, please write message in the comment section.
No comments:
Post a Comment