python selenium 处理悬浮窗口(baidu tj_more)

python selenium 处理悬浮窗口

from selenium.webdriver.common.action_chains import ActionChains
ActionChains(driver).move_to_element(e).perform()


#encode=utf-8
from selenium import webdriver
import time
from selenium.webdriver.common.action_chains import ActionChains
driver=webdriver.Firefox()
driver.get("https://www.baidu.com")
driver.implicitly_wait(30)
e=driver.find_element_by_link_text("更多产品")
ActionChains(driver).move_to_element(e).perform()
time.sleep(0.5)
js="document.getElementsByName('tj_more')[0].click()"
driver.execute_script(js)
time.sleep(0.5)
driver.get_screenshot_as_file("D:\python\test\test.png")
driver.quit()
 
原文地址:https://www.cnblogs.com/yye2010/p/8652874.html