使用TouchAction
https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/touch-actions.md
详细文档
使用TouchAction().press(el0).moveTo(el1).release()
一、appium滑动界面怎么写
举例:手势滑动界面,从下向上
def test_move(self):
touch=TouchAction(self.driver)
# 方法一,直接写坐标:
#touch.press(x=731,y=2083).move_to(x=731,y=900).wait(20).release().perform()
#方法二
width1=self.driver.get_window_rect()['width']
height1=self.driver.get_window_rect()['height']
current_x= width1/2
y1=height1*4/5
y2=height1*1/5
touch.press(x=current_x, y=y1).wait(500).move_to(x=current_x,
y=y2).wait(200).release().perform()
二、手势解锁怎么写
def test_jiesuo(self):
TouchAction(self.driver).press(x=243,y=395).move_to(x=243,y=875).move_to(x=701,y=875).move_to(x=1199,y=875).release().perform()
三、MultiTouch
MultiTouch手势只有两种方法add,和perform。
add 用于向此MultiTouch添加另一个TouchAction。
当perform被调用时,所有被添加到多点触控的TouchActions发送到appium就像它们发生在同一时间进行。Appium首先一起执行所有TouchAction的第一个事件,然后执行第二个,依此类推。
用两根手指同时点击:
action0 = TouchAction().tap(el)
action1 = TouchAction().tap(el)
MultiAction().add(action0).add(action1).perform()