3

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.

  • No headless mode suggestions please.
  • Changing the browser location off the screen doesn't work because it still steals focus
  • Minimizing the browser doesn't work because it unminimizes when the switch to command is run

Here is how I'm switching windows:

for handle in driver.window_handles:
    driver.switch_to.window(handle)
Branden
  • 326
  • 1
  • 3
  • 14

2 Answers2

2

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.

Prophet
  • 32,350
  • 22
  • 54
  • 79
0

I think, If you deploy your Automation scripts to a VM (which is there in you Machine), You can continue to start working on your local browser and Your Automation script will run on a VM and will have a independent environment for the same.

cruisepandey
  • 28,520
  • 6
  • 20
  • 38