airtest上的滑动操作swipe
正常来说,方法一的滑动是生效的,但是在页面有蒙层或是其他怪异的情况下,可能就不生效了,再用方法二方法一:# 获取设备的高度和宽度width, height = device().get_current_resolution()# 校准滑动的起点和终点start_pt1 = (width / 2,height * 0.9)end_pt1 = (width / 2,height * 0.1)start
·
正常来说,方法一的滑动是生效的,
但是在页面有蒙层或是其他怪异的情况下,可能就不生效了,再用方法二
方法一:
# 获取设备的高度和宽度
width, height = device().get_current_resolution()
# 校准滑动的起点和终点,因为大部分app上下有底栏和顶部导航,不在滑动范围,所以这里的height不是从0.1开始
start_pt1 = (width / 2,height * 0.7)
end_pt1 = (width / 2,height * 0.3)
start_pt2 = (width *0.9,height / 2)
end_pt2 = (width *0.1,height / 2)
# 上滑N次:
for i in range(2):
swipe(start_pt1, end_pt1,1000)
sleep(1) # 等待设备的响应
# 左滑N次:
for i in range(2):
swipe(start_pt2 , end_pt2,1000)
sleep(1) # 等待设备的响应
方法二:
#下滑
poco("android.view.View").swipe([0.1, 0.9])
#上滑
poco("android.view.View").swipe([-0.1, -0.9])
#左滑
poco("android.view.View").swipe([-0.9, -0.1])
#右滑
poco("android.view.View").swipe([0.9,0.1])
或者:
在app定义的滑动区域内,执行滑动操作
#上滑
poco("com.lanjingren.ivwen:id/swipe_layout").swipe([0.1, -0.9])
#下滑
poco("com.lanjingren.ivwen:id/swipe_layout").swipe([-0.9, 0.1])
#右滑
poco("com.lanjingren.ivwen:id/swipe_layout").swipe([0.9101, 0.1])
#左滑
poco("com.lanjingren.ivwen:id/swipe_layout").swipe([-0.9, -0.1])
更多推荐
已为社区贡献1条内容
所有评论(0)