zoukankan      html  css  js  c++  java
  • 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)

  • 相关阅读:
    HDU1852 Beijing 2008(快速幂+特殊公式)
    HihoCoder 1570 : 小Hi与法阵(简单几何)
    【转】反素数
    【整理】线段树30题
    SPOJcot2 Count on a tree II (树上莫队)
    【总结】曼哈顿距离转切比雪夫距离
    【初识】树上分块
    基于Tablestore Tunnel的数据复制实战
    【New Feature】阿里云快照服务技术解析
    基于日志服务的GrowthHacking(1):数据埋点和采集(APP、Web、邮件、短信、二维码埋点技术)
  • 原文地址:https://www.cnblogs.com/kaibindirver/p/8873137.html
Copyright © 2011-2022 走看看