from selenium import webdriver import time driver=webdriver.Chrome() driver.get("http://www.douban.com/") time.sleep(2) driver.execute_script('window.open("http:www.163.com/")') time.sleep(2) driver.execute_script('window.open("http:www.jd.com/")') time.sleep(2) driver.execute_script('window.open("http:www.baidu.com/")') #回到第一个页面 pages=driver.window_handles driver.switch_to.window(pages[0])