selenium 双击操作\右击操作\鼠标悬停

 

from  selenium import  webdriver
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep

driver=webdriver.Firefox()
driver.get("http://www.baidu.com")
driver.maximize_window()

driver.find_element_by_css_selector("#kw").send_keys("Python")
element=driver.find_element_by_css_selector("#kw")
sleep(3)

#双击操作
ActionChains(driver).double_click(element).perform()
sleep(2)

#右击操作
ActionChains(driver).context_click(element).perform()
sleep(2)

#鼠标悬停
above=driver.find_element_by_css_selector(".pf")
ActionChains(driver).move_to_element(above).perform()
sleep(3)
driver.quit()

 

posted @ 2021-04-24 23:58  测试艺术家  阅读(149)  评论(0编辑  收藏  举报