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()
 

 

posted @ 2018-03-26 18:59  yye_2010  阅读(1085)  评论(0编辑  收藏  举报