其他分享
首页 > 其他分享> > web自动化测试(十二)控件交互进阶-ActionChains

web自动化测试(十二)控件交互进阶-ActionChains

作者:互联网

Actions

ActionChains两种写法

  1. 链式写法
ActionChains(driver).move_to_element(element).click(element).perform()
  1. 分布写法
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