selenium - webdriver - ActionChains类(鼠标操作)

ActionChains 类提供了鼠标操作的常用方法:

  • perform(): 执行所有 ActionChains 中存储的行为;

  • context_click(): 右击;

  • double_click(): 双击;

  • drag_and_drop(): 拖动;

  • move_to_element(): 鼠标悬停。

鼠标悬停操作

代码实现:

from selenium import webdriver
from selenium.webdriver import ActionChains

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

above = driver.find_element_by_link_text("设置")
ActionChains(driver).move_to_element(above).perform()

driver.quit()

  

参考资料:

www.testclass.net/selenium_python/mouse-event/

猜你喜欢

转载自www.cnblogs.com/studyddup0212/p/9028761.html