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

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

  • context_click(): 右击;

  • double_click(): 双击;

  • drag_and_drop(): 拖动;

  • move_to_element(): 鼠标悬停。

鼠标悬停操作

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

代码实现:

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/

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
  • 2021-06-22
  • 2021-10-09
  • 2022-01-16
猜你喜欢
  • 2021-07-03
  • 2022-12-23
  • 2021-12-13
  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
相关资源
相似解决方案