zoukankan      html  css  js  c++  java
  • python+selenium自动化测试鼠标双击、鼠标悬停、右键点击、鼠标拖动

    1、鼠标双击

    例如有些地方需要使用到双击修改信息等,就需要使用到鼠标双击模拟操作

    from selenium import webdriver

    from selenium.webdriver import ActionChains

    action_chains = ActionChains(self.driver)

    action_chains.double_click(self.driver.find_element(By.ID,"span_shorturl")).perform()

    2、右键单击

    例如右键之后会出现菜单

    from selenium import webdriver

    from selenium.webdriver import ActionChains

    action_chains = ActionChains(self.driver)

    action_chains.context_click(self.driver.find_element(By.ID,"span_shorturl")).perform()

    3、鼠标悬停

    from selenium import webdriver

    from selenium.webdriver import ActionChains

    action_chains = ActionChains(self.driver)

    action_chains.move_to_element(self.driver.find_element(By.ID,"span_shorturl")).perform()

    4、鼠标拖动:比如 拖动某个对象、拖动滚动条 

    #定位元素的源位置

    source = driver.find_element_by_id("id")

    #定位元素要移到到的目标位置
    target = driver.find_element_by_id("id")

    action_chains = ActionChains(self.driver)

    action_chains .drag_and_drop(source,target).perform()
  • 相关阅读:
    数据库与数据仓库的比较Hbase——Hive
    log4j 配置使用
    hadoop Datanode Uuid unassigned
    kafka相关文章引用
    kafka可靠性
    kafka基本原理
    html
    并发编程
    Python之系统交互(subprocess)
    网络编程
  • 原文地址:https://www.cnblogs.com/zz-1021/p/13777649.html
Copyright © 2011-2022 走看看