4

Everytime I do a get,

    for a in al: 
        browser.get(a)
        ...

the window of the browser gets on-top and I cannot do other things on the computer.

I am using python, Chrome driver and Windows 7.

How can I make the browser to stay in the backround and prevent it to get on-top of other windows every-time the browser.get(a) is taking place ?

Eduard Florinescu
  • 16,747
  • 28
  • 113
  • 179
  • you may want to check out some of the options you can add when you create your `webdriver.BROWSERHERE()` object. check out [link](http://stackoverflow.com/questions/12698843/how-do-i-pass-options-to-the-selenium-chrome-driver-using-python) for instructions on how to do it and [link](http://peter.sh/experiments/chromium-command-line-switches/) for a list of chrome options to get you started – TehTris May 24 '13 at 19:31

1 Answers1

2

When the browser is launched, it's up to the OS whether it comes up in focus/in front or not, there's not much you can do (unless you modify Selenium itself to change the way it launches the subprocess with the browser in it). If you are on an OS that supports it though, you could integrate pyvirtualdisplay in to your tests and launch Selenium in to an XVFB session or something similar, though then you'd need to switch the virtual display off if you wanted to be able to watch the test run in the browser.

Silas Ray
  • 25,682
  • 5
  • 48
  • 63
  • It seems you are right but it seems it doesn't work either with tools that hide it in the tray, for every get it comes on-top again. – Eduard Florinescu May 24 '13 at 18:29
  • It's unlikely it can work while minimized, so I can see why each call will bring it back up if you are trying to minimize it, but if you just send it to the background, it should continue working in the background, only bringing a window to front when you launch a new browser window. – Silas Ray May 24 '13 at 18:31