I'm using selenium to run the code. However, at some point when I click the button, the form opens in a new tab and the code fails to continue. How do I make selenium recognize that it should continue in the new tab?
CodePudding user response:
You can do it by using window_handles
and switch_to.window
method:
last_tab = driver.window_handles[-1]
driver.switch_to.window(last_tab)
Then to switch back to the first tab use
driver.switch_to.window( driver.window_handles[0] )