Start webdriver session in minimized window ?

  • 1 Replies
  • 2957 Views
Start webdriver session in minimized window ?
« on: March 10, 2016, 10:22:36 am »
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

*

Oren

  • **
  • 59
Re: Start webdriver session in minimized window ?
« Reply #1 on: March 10, 2016, 13:03:28 pm »
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

Code
System.out.println("Minimizing...");
driver.manage().window().setPosition(new Point(-1000, 0));
      
you could always restore it later
Code
System.out.println("Restoring browser window...");
driver.manage().window().setPosition(new Point(0, 0));

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

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

 

Sitemap 1 2 3 4 5 6 7 8