鼠标事件
perform() #执行所有ActionChains中存储的行为
context_click() #右击事件
double_click() #双击事件
drag_and_drop(source,target) #拖动:source鼠标拖到的源元素,target鼠标释放的目标元素
move_to_element() #鼠标停留在一个元素上
click_and_hold() #按下鼠标左键在一个元素上
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains driver = webdriver.Firefox()
driver.get("http://www.baidu.com")
driver.maximize_window()
driver.implicitly_wait(3) #鼠标悬停在搜索设置按钮上
mouse = driver.find_element_by_link_text("设置") #定位到需要操作的元素
ActionChains(driver).move_to_element(mouse).perform() #鼠标悬停
#ActionChains(driver)用于生成模拟用户行为,调用ActionChains(),将浏览器驱动driver作为参数传入
#move_to_element() 鼠标悬停
# perform() 执行所有ActionChains中的行为,可以理解成是对整个操作的提交动作 ActionChains(driver).context_click(mouse).perform() #鼠标右击 ActionChains(driver).double_click(mouse).perform() #鼠标双击 element = driver.find_element_by_id("xx") #定位元素的原始位置
target = driver.find_element_by_id("xx") #定位元素要移动到的目标位置
ActionChains(driver).drag_and_drop(element,target).perform() #执行元素的拖放操作

最新文章

  1. cookie禁用了,session还能用吗?
  2. 烂泥:使KVM显示VM的IP地址及主机名
  3. [转]ASP.NET MVC Json()处理大数据异常解决方法 json maxjsonlength
  4. elclipse/myeclipse web.xml自动提示补全问题
  5. UnityShader快速上手指南(一)
  6. STL-算法
  7. (二). 细说Kalman滤波:The Kalman Filter
  8. 【风马一族_Android】让app上传到Android市场的网站介绍
  9. fingerprintjs
  10. BZOJ 1072 排列
  11. 【转】Understanding and Using rem Units in CSS
  12. Object-C 自学笔记 - 1
  13. Monkey and Banana(基础DP)
  14. Linux系统(三)系统基础扫盲大全
  15. java初学代码,还不太熟练
  16. centos7 + python 2.7 + pip + openvswitch 杂项问题
  17. CMM:软件成熟度模型
  18. 使用BootStrap框架中的轮播插件
  19. Hadoop生态圈-Kafka的旧API实现生产者-消费者
  20. repcached配置与简单測试

热门文章

  1. Docker打包 Asp.Net Core应用,在CentOS上运行(转)
  2. matplotlib坐标轴设置-【老鱼学matplotlib】
  3. Grafana和influxdb监控nginx日志中的请求响应时间图形化监控
  4. eclipse安装Spring的具体步骤
  5. Microsoft Office Word 中的公式自动编号
  6. 将ActiveX打包成CAB发布的注意事项
  7. (转载)CentOS6 Linux系统添加永久静态路由的方法
  8. SSH集成(Struts+Spring+Hibernate)
  9. Float.intBitsToFloat
  10. SSIS - 2.使用脚本任务弹出对话框