appium 滑动封装

#获得机器屏幕大小x,y

def  getSize():
     =  dr.get_window_size()[ 'width' ]
     =  dr.get_window_size()[ 'height' ]
     return  (x, y)
 
#屏幕向上滑动
def  swipeUp(t):
     =  getSize()
     x1  =  int (l[ 0 *  0.5 )   #x坐标
     y1  =  int (l[ 1 *  0.75 )    #起始y坐标
     y2  =  int (l[ 1 *  0.25 )    #终点y坐标
     dr.swipe(x1, y1, x1, y2,t)
#屏幕向下滑动
def  swipeDown(t):
     =  getSize()
     x1  =  int (l[ 0 *  0.5 )   #x坐标
     y1  =  int (l[ 1 *  0.25 )    #起始y坐标
     y2  =  int (l[ 1 *  0.75 )    #终点y坐标
     dr.swipe(x1, y1, x1, y2,t)
#屏幕向左滑动
def  swipLeft(t):
     l = getSize()
     x1 = int (l[ 0 ] * 0.75 )
     y1 = int (l[ 1 ] * 0.5 )
     x2 = int (l[ 0 ] * 0.05 )
     dr.swipe(x1,y1,x2,y1,t)
#屏幕向右滑动
def  swipRight(t):
     l = getSize()
     x1 = int (l[ 0 ] * 0.05 )
     y1 = int (l[ 1 ] * 0.5 )
     x2 = int (l[ 0 ] * 0.75 )
     dr.swipe(x1,y1,x2,y1,t)
#调用向左滑动
swipLeft( 1000 )
sleep( 3 )
#调用向右滑动
swipRight( 1000 )
调用向上滑动
swipeUp( 1000 )
调用向下滑动
swipeDown( 1000 )
 
后记:
自己搞了一个

class public_action:
def __init__(self,dr):
self.dr=dr
# 获取 屏幕宽度 和 高度 ,# 宽1018 ---x #长 1920 --y
self.size = self.dr.get_window_size()
self.width=self.size['width']
self.height=self.size['height']
# 向左滑动
def Slide_left(self):
self.dr.swipe(start_x=self.width*0.4, start_y=self.height*0.26, end_x=self.width*0.01, end_y=self.height*0.0026, duration=1000)
# 407.26 499.2 10.18 4.992
sleep(0.5)

# 向右滑动
def Slide_right(self):
self.dr.swipe(start_x=self.width*0.009, start_y=self.height*0.26, end_x=self.width*0.4, end_y=self.height*0.26, duration=1000)
# 9.62 500 400 500
sleep(0.5)

# 向上滑动
def Slide_up(self):
self.dr.swipe(start_x=self.width*0.5, start_y=self.height*0.88, end_x=self.width*0.5, end_y=self.height*0.36, duration=1000)
# 500 1700 500 700
sleep(0.5)

转载于:https://www.cnblogs.com/kaibindirver/p/8873137.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值