博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Air test 基于屏幕比例实现滑动的方法
阅读量:4987 次
发布时间:2019-06-12

本文共 3274 字,大约阅读时间需要 10 分钟。

# -*- encoding=utf8 -*-__author__ = "chenshanju"__docs__ = "基于iOS类实现滑动"from airtest.core.api import *from airtest.core.ios import IOSauto_setup(__file__)class Base():    def __init__(self):        test1=IOS()        self.width=test1.display_info['physical_width']        self.height=test1.display_info['physical_height']        self.left_point=(0.2*self.width,0.75*self.height)        self.right_point=(0.8*self.width,0.75*self.height)        self.up_point=(0.5*self.width,0.25*self.height)        self.down_point=(0.5*self.width,0.75*self.height)        self.back_point1=(0*self.width,0.5*self.height)        self.back_point2=(0.5*self.width,0.5*self.height)    def swipe_to_back(self):        swipe(self.back_point1,self.back_point2)    def swipe_to_left(self):        swipe(self.right_point,self.left_point)        sleep(2)    def swipe_to_right(self):        swipe(self.left_point,self.right_point)        sleep(2)    def swipe_to_up(self):        swipe(self.down_point,self.up_point)        sleep(2)    def swipe_to_down(self):        swipe(self.up_point,self.down_point)        sleep(2)    def exist_touch(self,p1,p2=0):        if p2==0:            p2=p1        if exists(p1):            touch(p2)            sleep(1)    def new_touch(self,p,t=1):        count=1        while not exists(p):                        sleep(5)            count=count+1            if count>5:                break        touch(p)        sleep(t)       def back_key(self):        count=0        back_list=[Template(file:///Users/chenshanju/Desktop/autoCase/feizhu/Base.air/tpl1536744539863.png, threshold=0.8, target_pos=5, rgb=False, record_pos=(-0.445, -0.901), resolution=(1125, 2436)),Template(file:///Users/chenshanju/Desktop/autoCase/feizhu/Base.air/tpl1536745663572.png, threshold=0.8, target_pos=5, rgb=False, record_pos=(0.4, -0.901), resolution=(1125, 2436)),Template(file:///Users/chenshanju/Desktop/autoCase/feizhu/Base.air/tpl1540368782186.png, threshold=0.8, target_pos=5, rgb=False, record_pos=(-0.433, -0.9), resolution=(1125, 2436)),Template(file:///Users/chenshanju/Desktop/autoCase/feizhu/Base.air/tpl1540372744293.png, record_pos=(-0.435, -0.902), resolution=(1125, 2436)),Template(file:///Users/chenshanju/Desktop/autoCase/feizhu/Base.air/tpl1536744539863.png, threshold=0.8, target_pos=5, rgb=False, record_pos=(-0.445, -0.901), resolution=(1125, 2436))]        for back in back_list:            count=count+1            if exists(back):                self.new_touch(back)                break            if count >= len(back_list):                  self.swipe_to_back()    def into_app(self):        start_app("com.taobao.travel")        sleep(5)        self.exist_touch(Template(file:///Users/chenshanju/Desktop/autoCase/feizhu/Base.air/tpl1536743118383.png, record_pos=(0.001, 0.004), resolution=(1125, 2436)),Template(file:///Users/chenshanju/Desktop/autoCase/feizhu/Base.air/tpl1536743125640.png, record_pos=(0.181, 0.156), resolution=(1125, 2436)))        def restart_app(self,p):        if exists(p):            self.new_touch(p)        else:            self.into_app()            sleep(5)            self.new_touch(p)# try:#     base = Base()#     base.into_app()# except:#     print(" regression base启动用例失败")

转载于:https://www.cnblogs.com/csj2018/p/9853232.html

你可能感兴趣的文章
过目不忘JS正则表达式
查看>>
Colidity-- StoneWall
查看>>
Leetcode 904. Fruit Into Baskets
查看>>
怎样连接REDIS服务端
查看>>
一些常用的js,jquerry 样例
查看>>
Oracle PL/SQL 多重选择句
查看>>
No.026:Remove Duplicates from Sorted Array
查看>>
SpringBoot项目的几种创建方式,启动、和访问
查看>>
解决"disabled". Expected Boolean, got Number with value 0
查看>>
OC--init,initialize,initWithCoder:,initWithFrame:各方法的区别和加载顺序
查看>>
Exponentiation
查看>>
本地jar上传到本地仓库
查看>>
四则运算C++带Qt界面版本,吾王镇楼。。。。。
查看>>
安卓7.0手机拍照闪退问题解决
查看>>
ME525+ Defy+ 刷机指南[zz]
查看>>
支持触屏的jQuery轮播图插件
查看>>
差一点搞混了Transactional注解
查看>>
javascript基本函数
查看>>
前端公共库cdn服务推荐//提高加载速度/节省流量
查看>>
snprintf 返回值陷阱 重新封装
查看>>