if the browser window is in bg, then this line doesn\'t work.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webd
Tested and works in Python 36
driver1 = webdriver.Chrome()
driver1.get("http://www.python.org")
pyName = driver1.title
pyHandle = driver1.window_handles[0]
driver2 = webdriver.Chrome()
driver2.get("http://www.ruby-lang.org/en")
rubyName = driver2.title
rubyHandle = driver2.window_handles[0]
#driver 2 at this time will be in the foreground
driver1.switch_to.window(pyHandle)
driver1.switch_to_window(driver1.current_window_handle)
Edit: switch_to_window is deprecated, use switch_to.window