鼠标右击、双击、悬停、拖动等功能,全部封装在ActionsChains类中

  perform()  :    执行所有ActionsChains中存储的行为

  context_click():       右击

  double_click():    双击

  drag_and_drop():    拖拽

  move_to_element():  鼠标悬停

 

例子:

1、鼠标悬停: 

from selenium.webdriver.common.action_chains import ActionChains

    loginName = driver.find_element_by_xpath('//*[@>)
    # 对定位到的元素进行鼠标悬停的动作
    ActionChains(driver).move_to_element(loginName).perform()
    #等待几秒
    sleep(3)
    #点击弹出的某个元素
    driver.find_element_by_link_text(u'  退出系统').click()

 

2、鼠标双击

codeArea = WebDriverWait(driver, 20, 1).until(EC.presence_of_element_located((By.XPATH, '//[@>)))
ActionChains(driver).double_click(codeArea).perform()

 

相关文章:

  • 2021-10-07
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
猜你喜欢
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2022-01-23
  • 2021-12-31
  • 2022-12-23
相关资源
相似解决方案