# -*- encoding=utf8 -*-
__author__ = "chenshanju"
__docs__ = "基于iOS类实现滑动"
from airtest.core.api import *
from airtest.core.ios import IOS
auto_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启动用例失败")

最新文章

  1. UIColor与PatternImage
  2. iOS开发-oc(菜鸟笔记)
  3. 把表里的数据转换为insert 语句
  4. 爬虫技术 -- 进阶学习(八)模拟简单浏览器(附c#代码)
  5. LoRaWAN移植笔记(一)__RTC闹钟链表的实现
  6. JavaScript--模块化编程(笔记)
  7. linux ps查看进程命令
  8. Android 内核初识(8)Binder
  9. (转载)Windows下手动完全卸载Oracle
  10. linux 系统下java开发环境的配置
  11. axure & Markman
  12. hdu_5818_Joint Stacks(线段树模拟)
  13. git 重命名本地分支,并提交到远程
  14. [UE4]瞬移之后的朝向
  15. <mvc:annotation-driven> 中的HttpMessageConverters 的理解
  16. Python学习第三篇——逻辑判定
  17. Vue系列之 => 评论功能(小知识点串联)
  18. S5PV210 看门狗定时和复位
  19. eclipse安装STS遇到的问题
  20. JS基础(四)运算符

热门文章

  1. (转载)YOLO配置文件理解
  2. POJ Stockbroker Grapevine(floyd)
  3. Redis哨兵(sentinel)
  4. Chain of Responsibility(责任链)
  5. [原][osgearth]osgearthElvation中的一帧
  6. HTML深入探究(一)HTML入门
  7. vSphere Client的拷贝 粘帖 功能
  8. CPU上下文切换详解
  9. 雷林鹏分享:Ruby 异常
  10. 机器学习算法--svm实战