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?
Asked
Active
Viewed 30 times
0
-
Does this answer your question? [How do I switch to the active tab in Selenium?](https://stackoverflow.com/questions/28715942/how-do-i-switch-to-the-active-tab-in-selenium) – JeffC Feb 01 '23 at 14:59
1 Answers
0
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] )

sound wave
- 3,191
- 3
- 11
- 29