鼠标事件

鼠标事件除了左键点击(click),还有其它的操作,这里介绍几种常用的鼠标事件:

1.鼠标右击

2.鼠标双击

3.鼠标悬停

4.鼠标拖动

在WebDriver 中这些关于鼠标操作的方法由ActionChains 类提供鼠标事件需要先导入模块:

from selenium.webdriver.common.action_chains importActionChains

鼠标右击:context_click()

Selenium2+Python2.0自动化测试【5】 鼠标事件

鼠标双击:double_click()

Selenium2+Python2.0自动化测试【5】 鼠标事件

鼠标悬停:move_to_element()

 Selenium2+Python2.0自动化测试【5】 鼠标事件

鼠标拖动:drag_and_drop(source, target)   

—source:鼠标按下的源元素;target:鼠标释放的目标元素

—如:element = driver.find_element_by_name("name")

         target = driver.find_element_by_name("name")

        ActionChains(driver).drag_and_drop(element, target).perform()


相关文章:

  • 2021-11-13
  • 2021-08-19
  • 2021-12-14
  • 2021-08-04
  • 2021-09-17
  • 2021-04-23
  • 2022-12-23
  • 2021-06-10
猜你喜欢
  • 2021-05-09
  • 2021-09-19
  • 2021-07-26
  • 2021-09-19
  • 2021-12-18
  • 2021-06-20
  • 2021-08-22
相关资源
相似解决方案