python-3.xseleniumselenium-chromedriversplinter

Switch to window (tab) without bringing browser to front


I am using Python and Selenium to navigate multiple tabs. How can I switch to a different window/tab without bringing the entire browser window to the front and without the selenium window "stealing" the focus of my computer? For example, if I'm typing in the search bar of a normal browser and my script switches tabs, it'll stop typing the search bar and I'll have to reclick the search bar to start typing again.

Here is how I'm switching windows:

for handle in driver.window_handles:
    driver.switch_to.window(handle)

Solution

  • The answer is NO, this is not possible to do with Selenium.
    Selenium is created to simulate actions a user can do via GUI.
    As a user you can't do what you are asking about, Selenium can't do it as well.