web自动化测试(十二)控件交互进阶-ActionChains
作者:互联网
Actions
- 官方文档:https://selenium-python.readthedocs.io/api.html
- ActionChains: 执行PC端的鼠标点击、双击、右击、拖拽等事件
- TouchActions:模拟执行PC端和移动端的点击、滑动、拖拽、多点触控等多种手势控制操作
ActionChains两种写法
- 链式写法
ActionChains(driver).move_to_element(element).click(element).perform()
- 分布写法
actions = ActionChains(driver)
actions.move_to_element(element)
actions.click(element)
actions.perform()
ActionChains API
actions = ActionChains(driver)
# 点击
actions.click(element)
# 双击
actions.double_click(element)
# 右击
actions.context_click(element)
# 鼠标移动到某个元素上
actions.move_to_element(element)
# 拖拽
actions.drag_and_drop(drag_element, drop_element)
# 按住不放
actions.click_and_hold(element)
# 模拟按键
actions.send_keys(Keys.BACK_SPACE)
# 按下抬起
actions.key_down(Keys.CONTROL).send_keys('a').key_up(Keys.CONTROL)
# 释放
actions.release()
标签:控件,进阶,web,ActionChains,move,driver,actions,element,click 来源: https://www.cnblogs.com/xxiaow/p/16328769.html