appium Action(滑动操作、连续滑动操作、多点触控)

滑动操作(swipe)

在Appium中模拟用户滑动操作需要使用swipe方法,该方法定义如下:

 def swipe(self, start_x, start_y, end_x, end_y, duration=None):        
 Swipe from one point to another point, for an optional duration.         
 :Args:        
   - start_x - x-coordinate at which to start        
   - start_y - y-coordinate at which to start        
   - end_x - x-coordinate at which to stop        
   - end_y - y-coordinate at which to stop        
   - duration - (optional) time to take the swipe, in ms.

屏幕坐标:

原点坐标位于屏幕的左上角,x轴向右逐渐增大,y轴向下变大

案例

此案例直接时滑动屏幕,不对任何app操作,所以未设置appPacage等参数

from appium import webdriver
from time import sleep

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1.1'
desired_caps['deviceName'] = '127.0.0.1:21503'

webdr = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps)
webdr.implicitly_wait(10)

# 封装获取

猜你喜欢

转载自blog.csdn.net/Mwyldnje2003/article/details/104030700