I use Firefox. I click a button but the page opens as a new tab and selenium stays focused on the original page with the button. I'm trying to switch and get the new url.
time.sleep(4)
second_driver.switch_to.window(second_driver.window_handles[1])
print(second_driver.current_url)
I get:
selenium.common.exceptions.InvalidArgumentException: Message: Expected "handle" to be a string, got [object Undefined] undefined
I also tried the following but it didn't have an effect. I still got the url of the old page.
second_driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + Keys.TAB)