I will tell you how to maximize a browser window using a web driver. Here is a Selenium script with an explanation.
Script Description: In the below Selenium script shown the maximize of the browser using the testNG framework, steps of the scenario are :
- Open the Chrome browser.
- Launch the site.
- Wait for a few seconds to view the maximize action.
- Close the browser.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Maximize {
public static void main(String args[]) throws InterruptedException
{ WebDriver driver;
System.setProperty("webdriver.chrome.driver","E://Selenium//Selenium_Jars//chromedriver.exe");
driver= new ChromeDriver();
// Launch the application
driver.get("https://www.intellipaat.com/");
//Resize current window to the set dimension
driver.manage().window().maximize();
//To Delay execution for 10 sec. as to view the maximize browser
Thread.sleep(10000);
//Close the browser
driver.quit();
}
}
The Output Analysis is as follows:
It automatically opens the chrome browser, maximizes the browser, waits for a few seconds and closes the browser.