How do I switch to the active tab in Selenium?

This actually worked for me in 3.x:

driver.switch_to.window(driver.window_handles[1])

window handles are appended, so this selects the second tab in the list

to continue with first tab:

driver.switch_to.window(driver.window_handles[0])

Leave a Comment