MultiAction是针对多点触控操作的,是TouchAction的一个补充模块 TouchAction用法参考前面的一篇:appium+python自动化33-解锁九宫格(TouchAction)
class MultiAction(object):
def __init__(self, driver, element=None):
self._driver = driver
self._element = element
self._touch_actions = []
def add(self, *touch_actions):
"""添加TouchAction事件
:Args:
- touch_actions - one or more TouchAction objects describing a chain of actions to be performed by one finger
:Usage:
a1 = TouchAction(driver)
a1.press(el1).move_to(el2).release()
a2 = TouchAction(driver)
a2.press(el2).move_to(el1).release()
MultiAction(driver).add(a1, a2)
"""
def perform(self):
"""Perform the actions stored in the object.
:Usage:
a1 = TouchAction(driver)
a1.press(el1).move_to(el2).release()
a2 = TouchAction(driver)
a2.press(el2).move_to(el1).release()
MultiAction(driver).add(a1, a2).perform()
"""
from appium.webdriver.common.touch_action import TouchAction
from appium.webdriver.common.multi_action import MultiAction
# el是定位元素的对象
action0 = TouchAction().tap(el)
action1 = TouchAction().tap(el)
MultiAction().add(action0).add(action1).perform()
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有