网页页面之间的切换
2021-01-15 04:14
标签:switch color script port www pen sele class handles 网页页面之间的切换 标签:switch color script port www pen sele class handles 原文地址:https://www.cnblogs.com/luckiness/p/13401465.htmlfrom 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])