Selenium won’t open a new URL in a new tab (Python & Chrome)

Here is a simple way, platform independent:

Code:

driver.execute_script("window.open('http://google.com', 'new_window')")

Switching back to the original tab:

Code:

driver.switch_to_window(driver.window_handles[0])

Checking the current title to be sure you are on the right page:

Code:

driver.title

For everything else, have fun!

Leave a Comment