比如pinch:两个手指向内滑动 zoom:两个手指向外滑动
首先
from appium.webdriver.common.touch_action import TouchAction
from appium.webdriver.common.multi_action import MultiAction
def pinch(): action1=TouchAction(driver) action2=TouchAction(driver) pinch_action=MultiAction(driver) action1.press(x=x*0.2,y=y*0.2).wait(1000).move_to(x=x*0.4,y=y*0.4).wait(1000).release() action2.press(x=x*0.8,y=y*0.8).wait(1000).move_to(x=x*0.6,y=y*0.6).wait(1000).release() pinch_action.add(action1,action2) print('start pinch...') pinch_action.perform()
def zoom(): action1 = TouchAction(driver) action2 = TouchAction(driver) zoom_action = MultiAction(driver) action1.press(x=x * 0.4, y=y * 0.4).wait(1000).move_to(x=x * 0.2, y=y * 0.2).wait(1000).release() action2.press(x=x * 0.6, y=y * 0.6).wait(1000).move_to(x=x * 0.8, y=y * 0.8).wait(1000).release() zoom_action.add(action1,action2) print("start zoom...") zoom_action.perform()