首页 > 移动平台 > 详细

Python3 + seleium鼠标移动拖拽双击、长按等操作

时间:2020-06-24 11:34:54      阅读:112      评论:0      收藏:0      [点我收藏+]

Python3 + seleium鼠标移动拖拽双击、长按等操作

1、move_to_ element(to_element)鼠标移动到指定元素

element = driver.find_element_by_id(xxx)
ActionChains(driver).move_to_element(element).perform()

2、move_ to_ element_ with_ offset(to_element, xoffset, yoffset)
鼠标往右上方横向纵向各移动100

element = driver.find_element_by_id(xxx)
ActionChains(driver).move_to_element_with_offset(element, 100, 100).perform()

3、double_click(on_element=None)
双击元素,如果没有指定元素则在当前鼠标位置双击

element = driver.find_element_by_id(xxx)
ActionChains(driver).double_click(element).perform()

4、context_click(on_ element=None)
在元素上点击鼠标右键,如果没有指定则在当前鼠标位置单击右键

element = driver.find_element_by_id(xxx)
ActionChains(driver).context_click(element).perform()

5、click_and_hold(on_element=None) 鼠标按下不松

element = driver.find_element_by_id(xxx )
ActionChains(driver).click_and_hold(element).perform()

6、drag_and_drop(source, target)
按住element1元素,拖动到element2元素。

element1 = driver.find_element_by_id(source" )
element2 = driver.find_element_by_id(target )
ActionChains(driver).drag_and_drop(element1, element2).perform()

7、drag_and_drop_ by_ ofet(source_xoffset, yofiset)
向左上角横向纵向移动100。

element = driver.find_element_by_id(source)
ActionChains(driver).drag_and_drop_by_offset(element, -100, -100).perform()

 

Python3 + seleium鼠标移动拖拽双击、长按等操作

原文:https://www.cnblogs.com/lizm166/p/13186226.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!