首页 > 编程语言 > 详细

python自动化测试——鼠标事件(ActionChains类)

时间:2019-02-15 14:37:40      阅读:386      评论:0      收藏:0      [点我收藏+]
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://www.***.cn")

ele = driver.find_element(By.CSS_SELECTOR,"***")
target = driver.find_element(By.CSS_SELECTOR,"***")
#鼠标悬停
ActionChains(driver).move_to_element(ele).perform()

#右键
ActionChains(driver).context_click(ele).perform()

#双击
ActionChains(driver).double_click(ele).perform()

#拖动到目标位置
ActionChains(driver).drag_and_drop(ele,target).perform()

#向右下拖拽
ActionChains(driver).click_and_hold(ele).move_by_offset(xoffset=500, yoffset=500).release().perform()
#向右拖拽
ActionChains(driver).click_and_hold(ele).move_by_offset(xoffset=500, yoffset=0).release().perform()
#向下拖拽
ActionChains(driver).click_and_hold(ele).move_by_offset(xoffset=0, yoffset=500).release().perform()

driver.quit()

 

python自动化测试——鼠标事件(ActionChains类)

原文:https://www.cnblogs.com/nicole-zhang/p/10383368.html

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