# 定义ActionChains 实例
actions = ActionChains(driver)
# 第一步:定义输入源
# ActionChains里有个属性是ActionBuilder类型的, 使用的就是w3c协议
# 可以定义鼠标指针源,键盘源,滚轮源事件
actions.w3c_actions = ActionBuilder(driver, mouse=PointerInput(interaction.POINTER_TOUCH, "touch"))
# 第二步:定义动作
# 移动到起点
actions.w3c_actions.pointer_action.move_to_location(118, 176)
# 按下
actions.w3c_actions.pointer_action.pointer_down()
actions.w3c_actions.pointer_action.pause(0.5)
# 移动到第二个点
actions.w3c_actions.pointer_action.move_to_location(362, 176)
actions.w3c_actions.pointer_action.pause(0.5)
# 移动到第三个点
actions.w3c_actions.pointer_action.move_to_location(600, 176)
actions.w3c_actions.pointer_action.pause(0.5)
# 移动到第四个点
actions.w3c_actions.pointer_action.move_to_location(600, 423)
actions.w3c_actions.pointer_action.pause(0.5)
# 移动到最后个点
actions.w3c_actions.pointer_action.move_to_location(600, 659)
# 释放
actions.w3c_actions.pointer_action.release()
# 执行
actions.perform()
评论