I am working on selenium to retrieve learning stuff:
During the executing of my code, the target website will defensively open a new tab to stop my process.
I tried to check the current_url
, but it does not work as expected
if browser.current_url != start_url:
browser.switch_to.window(browser.window_handles[0])
How could I check like this:
if browser.current_tab != tab[0]:
browser.switch_to.window(browser.window_handles[0])
cached = driver.current_window_handle
to save the start status first, then check byif cached in browser.window_handles
? – MT-FreeHK Aug 20 '18 at 4:38