When we launch a browser using Selenium WebDriver, by default it is not in its maximized state. In this post, we will see how to maxmize and minimize a browser during automation.
During automation its one of the best practices to maximize the browser in the initial phases (or in the @BeforeTest method in case you are using TestNG as the testing framework). The following command can be used to maximize the browser window.
Unfortunately Selenium WebDriver doesn't provide any native supoort for minimizing a browser. If we don't want to see the browser in action during automation than we can use Headless browsers like HTMLUnitDriver, PhantomJS etc. But in case we specifically want to minimize a browser during automation than we can make use of the below statement. The following code snippet will position the browser to an area that is not within the viewable section of the machine we are working on. Thus making it appear as if the browser window got minimized.