TestProject Forum
Powered by leading experts in the test automation community

Start webdriver session in minimized window?

Is it possible to minimize the browser to the taskbar using one of selenium’s methods ?

Assuming i’d want to delay execution for a bit, or just execute things in the background

Selenium itself does not support any method to minimize the browser window equivalent to window.maximize()

However there’s a nice trick you could do by setting the window position out of your sight

System.out.println("Minimizing..."); driver.manage().window().setPosition(new Point(-1000, 0));

you could always restore it later

System.out.println("Restoring browser window..."); driver.manage().window().setPosition(new Point(0, 0));

or just call driver.manage().window().maximize();

If you’d like to run automated tests without seeing the window at all you could always use PhantomJS driver.