1 from selenium import webdriver
2 from selenium.webdriver.common.keys import Keys
3 import time
4
5 # 加载配置文件免登录
6 profileDir =r'C:\Users\Administrator\AppData\Roaming\Mozilla\Firefox\Profiles\yn80ouvt.default'
7 profile = webdriver.FirefoxProfile(profileDir)
8 driver = webdriver.Firefox(profile)
9 driver.get("https://www.baidu.com/")
10 # 修改元素的 target 属性
11 js = 'document.getElementsByClassName("mnav")[0].target="";'
12 driver.execute_script(js)
13 driver.find_element_by_link_text("学术").click()
14 print("link:学术")
15 print(driver.get_window_size())
16 driver.quit()