简体   繁体   中英

Selenium: How to stop the browser window getting on-top for every get?

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM