# -*- 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启动用例失败")

Air test 基于屏幕比例实现滑动的方法的更多相关文章

  1. 基于屏幕空间的实时全局光照(Real-time Global Illumination Based On Screen Space)

    目录 Reflective Shadow Maps(RSM) RSM 的重要性采样 RSM 的应用与缺陷 Screen Space Ambient Occulsion(SSAO) SSAO Blur ...

  2. 基于 jQuery 实现垂直滑动的手风琴效果

    今天我们要与大家分享一个漂亮而灵活的垂直 jQuery 手风琴效果.其主要思想是扩大手风琴片上的点击和显示更多的信息.其他内容片段将变得不那么透明.当使用一个导航箭头导航下一个片段,新的片会从顶部或底 ...

  3. 关于android MTK相机L版本,切换屏幕比例后,分辨率随之改变,但重新进入相机后原有分辨率不再生效问题

    BUG详细:比如4:3的时候是200W,切成全屏变400W,重新切回4:3为300W,退出相机后,重新进入又变成200W. 原因分析:这个版本的设计如此,当你点选屏幕比例的时候,程序设计是把这个比例值 ...

  4. 基于jQuery鼠标滚轮滑动到页面节点部分

    基于jQuery鼠标滚轮滑动到页面节点部分.这是一款基于jQuery+CSS3实现的使用鼠标滚轮或者手势滑动到页面节点部分特效.效果图如下: 在线预览   源码下载 实现的代码. html代码: &l ...

  5. 基于jQuery图片遮罩滑动文字切换特效

    基于jQuery图片遮罩滑动文字切换特效.这是一款jquery hover鼠标滑动选项卡切换透明背景遮罩文字显示特效.效果图如下: 在线预览   源码下载 实现的代码. html代码: <div ...

  6. 基于HTML5手机上下滑动翻页特效

    基于HTML5手机上下滑动翻页特效.这是一款手机移动端触屏滑动翻页代码下载.效果图如下: 在线预览   源码下载 实现的代码. html代码: <section class="u-al ...

  7. appium学习【五】【转】appium实现屏幕向左滑动

    转自http://www.cnblogs.com/testhub/p/5949668.html 前些日子写一个滑动手机页面的小脚本,看到大家给的内容都是swipe方法,这里对swipe方法做一个小介绍 ...

  8. 根据bootstrap框架实现移动端触摸滑动的方法

    有一个移动端的项目要求用jquery+bootstrap,其中有一个轮播图,需求是要求可以手触滑动,但是bootstrap中没有写手触滑动的方法,自己琢磨着写了出来,供大家参考. $(function ...

  9. appium 处理滑动的方法

    appium 处理滑动的方法是 swipe(int start-x, int start-y, int end-x, int end-y, int during) - Method in class ...

随机推荐

  1. Coursera SDN M1.2.1 SDN History: Programmable Networks 1

    接上第二点 NOTE (2)active networks => Programmability in networks(1990s) Sturcture: What are active ne ...

  2. HDU 3315 My Brute(二分图最佳匹配+尽量保持原先匹配)

    http://acm.hdu.edu.cn/showproblem.php?pid=3315 题意: 有S1到Sn这n个勇士要和X1到Xn这n个勇士决斗,初始时,Si的决斗对象是Xi. 如果Si赢了X ...

  3. 往前端打smarty数据

    $data['hot_issue']=$hotIssue; var_dump($data);

  4. hdu KiKi's K-Number 主席树

    KiKi's K-Number Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  5. postman 安装桌面版

    https://github.com/postmanlabs/postman-app-support

  6. Qt5_vs2013_error_C2001: 常量中有换行符__资料

    ZC: Win7x64 + Qt551(x86) + vs2013(x86) ZC: 问题:UTF-8 在源码文件中有中文时,有时会报编译错误:C2001 & C2143 分析: --> ...

  7. 这是一份很详细的 Retrofit 2.0 使用教程(含实例讲解)

    前言 在Andrroid开发中,网络请求十分常用 而在Android网络请求库中,Retrofit是当下最热的一个网络请求库 今天,我将献上一份非常详细Retrofit v2.0的使用教程,希望你们会 ...

  8. 【源码学习之spark core 1.6.1 各种部署模式所使用的的TaskSceduler及SchedulerBackend】

    说明:个人原创,转载请说明出处 http://www.cnblogs.com/piaolingzxh/p/5656879.html 未完待续 未完待续

  9. [POI2012]ROZ-Fibonacci Representation (数学)

    大意:给定n, 求至少要多少个斐波那契数相加减后能得到n  (可以重复, 重复的算多次) 假设$dp(x)$为$x$的最小划分, 有$dp(x)=dp(x-F_k)+1$, 其中$F_k$为最接近$x ...

  10. HDU - 4812 D Tree 点分治

    http://acm.hdu.edu.cn/showproblem.php?pid=4812 题意:有一棵树,每个点有一个权值要求找最小的一对点,路径上的乘积mod1e6+3为k 题解:点分治,挨个把 ...