Search code examples
seleniumselenium-webdriverwebdriverselenium-grid

Can Selenium WebDriver open browser windows silently in the background?


I have a Selenium test suite that runs many tests and on each new test it opens a browser window on top of any other windows I have open. Very jarring while working in a local environment. Is there a way to tell Selenium or the OS (Mac) to open the windows in the background?


Solution

  • There are a few ways, but it isn't a simple "set a configuration value". Unless you invest in a headless browser, which doesn't suit everyone's requirements, it is a little bit of a hack:

    How to hide Firefox window (Selenium WebDriver)?

    and

    Is it possible to hide the browser in Selenium RC?

    You can 'supposedly', pass in some parameters into Chrome, specifically: --no-startup-window

    Note that for some browsers, especially Internet Explorer, it will hurt your tests to not have it run in focus.

    You can also hack about a bit with AutoIt, to hide the window once it's opened.