Air test 基于屏幕比例实现滑动的方法
# -*- 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 基于屏幕比例实现滑动的方法的更多相关文章
- 基于屏幕空间的实时全局光照(Real-time Global Illumination Based On Screen Space)
目录 Reflective Shadow Maps(RSM) RSM 的重要性采样 RSM 的应用与缺陷 Screen Space Ambient Occulsion(SSAO) SSAO Blur ...
- 基于 jQuery 实现垂直滑动的手风琴效果
今天我们要与大家分享一个漂亮而灵活的垂直 jQuery 手风琴效果.其主要思想是扩大手风琴片上的点击和显示更多的信息.其他内容片段将变得不那么透明.当使用一个导航箭头导航下一个片段,新的片会从顶部或底 ...
- 关于android MTK相机L版本,切换屏幕比例后,分辨率随之改变,但重新进入相机后原有分辨率不再生效问题
BUG详细:比如4:3的时候是200W,切成全屏变400W,重新切回4:3为300W,退出相机后,重新进入又变成200W. 原因分析:这个版本的设计如此,当你点选屏幕比例的时候,程序设计是把这个比例值 ...
- 基于jQuery鼠标滚轮滑动到页面节点部分
基于jQuery鼠标滚轮滑动到页面节点部分.这是一款基于jQuery+CSS3实现的使用鼠标滚轮或者手势滑动到页面节点部分特效.效果图如下: 在线预览 源码下载 实现的代码. html代码: &l ...
- 基于jQuery图片遮罩滑动文字切换特效
基于jQuery图片遮罩滑动文字切换特效.这是一款jquery hover鼠标滑动选项卡切换透明背景遮罩文字显示特效.效果图如下: 在线预览 源码下载 实现的代码. html代码: <div ...
- 基于HTML5手机上下滑动翻页特效
基于HTML5手机上下滑动翻页特效.这是一款手机移动端触屏滑动翻页代码下载.效果图如下: 在线预览 源码下载 实现的代码. html代码: <section class="u-al ...
- appium学习【五】【转】appium实现屏幕向左滑动
转自http://www.cnblogs.com/testhub/p/5949668.html 前些日子写一个滑动手机页面的小脚本,看到大家给的内容都是swipe方法,这里对swipe方法做一个小介绍 ...
- 根据bootstrap框架实现移动端触摸滑动的方法
有一个移动端的项目要求用jquery+bootstrap,其中有一个轮播图,需求是要求可以手触滑动,但是bootstrap中没有写手触滑动的方法,自己琢磨着写了出来,供大家参考. $(function ...
- appium 处理滑动的方法
appium 处理滑动的方法是 swipe(int start-x, int start-y, int end-x, int end-y, int during) - Method in class ...
随机推荐
- webpack执行中出现 ERROR in Path must be a string. Received undefined
执行webpack时出现错误信息 ERROR in Path must be a string. Received undefined 原因在于我的node.js版本太高了,目前node版本为6.10 ...
- .Net Core中使用UEditor
一.下载解压UEditor的.net版本(这个直接使用的话是asp.net的版本) 我下载的是这个 再给留上地址http://ueditor.baidu.com/website/download.ht ...
- PHP处理Ajax请求与Ajax跨域
PHP判断是否为Ajax请求 我们知道,在发送ajax请求的时候,可以通过XMLHttpRequest这个对象,创建自定义的header头信息, 在jquery框架中,对于通过它的$.ajax, $. ...
- Appium 自动化测试(8) -- Appium Python client -- API
最好的学习方法,就是看源码! 在 \appium\webdriver\webdriver.py ,新增了两个封装好定位安卓元素的方法,如 find_element_by_accessibility ...
- MySQL重装
一.在控制面板中卸载程序 二.找到安装目录,删除掉剩余的文件,一般在C:\Program Files\MySQL\和C:\ProgramData\MySQL\ 三.清理注册表,在“运行”里键入rege ...
- 012PHP文件处理——copy rename file set_include_path
<?php //copy rename file set_include_path /*file() 以行为单位返回数组 * */ /*$arr=file('b.txt'); foreach ( ...
- 基于Jquery实现省份、城市、区县三级联动
前端感觉写的比较少,也是为了练手,下午没事用来写了这个三级联动,也是第一次写这东西. 据我了解,城市信息可以选择存在数据库或者直接写在前端,为了省事,我直接写在前端,下面是我的代码: <!DOC ...
- 在ASP.NET中将GridView数据导出到Word、Excel
在ASP.NET中将GridView数据导出到Word.Excel asp.net,导出gridview数据到Word,Excel,PDF #region Export to Word, Exce ...
- OMAP4之DSP核(Tesla)软件开发学习(一)
目的: 目前手上正在OMAP4上做东西,由于涉及到大量运算,交给arm A9双核发现运算速度很慢,不能满足需求.故考虑将大量运算任务(比如FIR.FFT.卷积.图像处理.向量运算等)交给O ...
- secureCRT连不上虚拟机上的ubuntu
前些日子我的secureCRT一直连不上虚拟机上的ubuntu,虽然两边的IP都能ping通! 都怪我当初连ssh都没装就在那瞎弄,执行以下第二步即可连接上了. 如何使用SecureCRT连接ubun ...