第三十节 selenium打开多个窗口和切换
作者:互联网
1 from selenium import webdriver 2 from selenium.webdriver.chrome.options import Options 3 4 5 browers_path = r'C:\Users\Administrator\AppData\Local\360Chrome\Chrome\Application\360chrome.exe' 6 chrome_option = Options() 7 chrome_option.binary_location = browers_path 8 browers_driver = webdriver.Chrome(options=chrome_option) 9 browers_driver.get("http://www.baidu.com") 10 browers_driver.execute_script('window.open("https://www.douban.com")') 11 window_list = browers_driver.window_handles#获取窗口列表 12 browers_driver.switch_to.window(window_list[1])#将browers_driver的指针转移到指定的窗口 13 print(browers_driver.current_url)#打印browers_driver指向的窗口网址
标签:第三十,chrome,browers,driver,window,切换,option,selenium 来源: https://www.cnblogs.com/kogmaw/p/12507143.html