1# Open a new window
2browser.execute_script("window.open('');")# Switch to the new window and open URL B
3browser.switch_to.window(browser.window_handles[1])
4browser.get(tab_url)
1from selenium import webdriver
2from selenium.webdriver.common.keys import Keys
3
4driver = webdriver.Firefox()
5driver.get("http://www.google.com/")
6
7#open tab
8driver.find_element_by_tag_name('body').send_keys(Keys.COMMAND + 't')
9# You can use (Keys.CONTROL + 't') on other OSs
10
11# Load a page
12driver.get('http://stackoverflow.com/')
13# Make the tests...
14
15# close the tab
16# (Keys.CONTROL + 'w') on other OSs.
17driver.find_element_by_tag_name('body').send_keys(Keys.COMMAND + 'w')
18
19
20driver.close()