1.  Pymysql(No module named cryptography)

pip install cryptography

pip install paramiko

把 cryptography 与pymysql 放入 airtest路径

2.  安装,卸载

方法一(原生adb):

以mac 为例,首先找到airtest adb 的路径,例如:/Applications/AirtestIDE.app/Contents/MacOS/airtest/core/android/static/adb/mac/。以下操作均为adb路径+命令(adb路径简写为adb

1. 查看所连接的设备

os.system('adb version')

2. 查看所有包名

os.system('adb shell pm list package')

3. 安装

os.popen("adb install -r D:\BaiduYunDownload\kaoyan3.1.0.apk")

4. 卸载

os.system('adb uninstall com.fenbi.android.zenglish')

5. 启动app

def call_adb(str):
  rec = os.system("/Applications/AirtestIDE.app/Contents/MacOS/airtest/core/android/static/adb/mac/adb %s" % str)
  return rec
call_adb("shell dumpsys activity activities") # 找package+actity

(2) 找到cmp

(3) call_adb("shell am start -n com.fenbi.android.zenglish/com.fenbi.android.zebraenglish.activity.portal.WelcomeActivity") #package+actity

方法二:

from airtest.core.android.android import Android
command = Android()

print("当前设备:%s"% command.get_default_device())
print("uuid:%s"% command.uuid)
print("手机里所有的app:%s"% command.list_app())
print("启动app:%s"% command.start_app('com.tencent.mtt'))
print("停止app:%s"% command.stop_app('com.tencent.mtt'))
print("清除app数据:%s"% command.clear_app('com.tencent.mtt'))
print("安装app:%s"% command.install_app('/Users/zd/Downloads/zenglish-3.13.0-fenbi-test.apk'))
print("卸载app:%s"% command.uninstall_app('com.tencent.mtt'))
print("唤醒:%s"% command.wake())
print("home:%s"% command.home())
print("手机是否灭屏返回值:%s"% command.is_screenon())
print("手机里的app是否存在:%s"% command.check_app('com.tencent.mtt'))

方法三:

from airtest.core.api import *

stop_app('com.fenbi.android.zenglish')
start_app('com.fenbi.android.zenglish')
clear_app('com.fenbi.android.zenglish')
install('/Users/zd/Downloads/zenglish-3.13.0-fenbi-test.apk')
uninstall('com.fenbi.android.zenglish')
wake()
home()

1. 点击并长按

# coding=utf-8

from poco.drivers.unity3d import UnityPoco

poco = UnityPoco()

poco('btn_start').click()poco('basic').click()poco('star_single').long_click()poco('star_single').long_click(duration=5)

poco(text='分享').click()

2. 存在

obj = poco(text='分享',type='android.widget.RadioButton')

if obj.exists(): #True

print('返回Ture')

else:

print('返回False')

3. 选择

  1. 属性

poco(text='分享',type='android.widget.RadioButton')

  1. 遍历子代

rec = poco("android.view.ViewGroup").offspring("android.widget.TextView")

print('%%%%%%%%%%%s'%len(rec))

for i in range(len(rec)):

print(rec[i].get_text())

4. 获得属性

print(obj.get_text())

print(obj.attr('text'))

print(obj.attr('package'))

5. 拖动

poco('star').drag_to(poco('shell'))

6. 滑动

obj.swipe([0, 0.8],duration=3)

obj.swipe('up')

obj.swipe('down')

obj.swipe('left')

obj.swipe('right')

x,y=obj.get_position()

obj.swipe([x,y],[x*0.6,y*0.6])

6. 放大,缩小

from airtest.core.api import *

poco('android:id/content').pinch('in',percent=0.2)

poco('android:id/content').pinch('out',percent=0.2)

7. focus

listView = poco('Scroll View')

listView.focus([0.5, 0.8]).drag_to(listView.focus([0.5, 0.2]))

image.focus('center').long_click()

image.focus([0.1, 0.1]).long_click()

8. wait

# coding=utf-8

from poco.drivers.unity3d import UnityPocofrom poco.exceptions import PocoTargetTimeout

poco = UnityPoco()

bomb_count = 0

while True:

blue_fish = poco('fish_emitter').child('blue')

yellow_fish = poco('fish_emitter').child('yellow')

bomb = poco('fish_emitter').child('bomb')

fish = poco.wait_for_any([blue_fish, yellow_fish, bomb])

if fish is bomb:

# skip the bomb and count to 3 to exit

bomb_count += 1

if bomb_count > 3:

return

else:

# otherwise click the fish to collect.

fish.click()

time.sleep(2.5)

案例二:

# coding=utf-8

import timefrom poco.drivers.unity3d import UnityPoco

poco = UnityPoco()

poco(text='wait UI 2').click()

blue_fish = poco('fish_area').child('blue')

yellow_fish = poco('fish_area').child('yellow')

shark = poco('fish_area').child('black')

poco.wait_for_all([blue_fish, yellow_fish, shark])

poco('btn_back').click()

time.sleep(2.5)

9. 生成测试报告

Ctr+L

10. 关于文件导入

from airtest.core.api import *

import os

print(os.path.abspath(os.path.dirname(os.getcwd())))
ST.PROJECT_ROOT =os.path.abspath(os.path.dirname(os.getcwd()))
using("untitled.air")
from ttest import *

Airtest ——poco的更多相关文章

  1. 5分钟上手自动化测试——Airtest+Poco快速上手

    版权声明:该文章为AirtestProject原创文章:允许转载,但转载必须注明“转载”并保留原链接 前言 本文档将演示使用`AirtestProject`专用的编辑器AirtestIDE,编写`Ai ...

  2. airtest+poco多脚本、多设备批处理运行测试用例自动生成测试报告

    一:主要内容 框架功能及测试报告效果 airtest安装.环境搭建 框架搭建.框架运行说明 airtest自动化脚本编写注意事项 二:框架功能及测试报告效果 1. 框架功能: 该框架笔者用来作为公司的 ...

  3. Airtest Project的探索和使用

    Airtest使用参考博文: https://testerhome.com/topics/12391 1. 安装Python 3 2. 安装pip: 安装方法参考另外一篇随笔 pip3部署: C:\U ...

  4. 一种新的自动化 UI 测试解决方案 Airtest Project

    今天分享一个自动化UI测试工具airtest——一款网易出品的基于图像识别面向游UI测试的工具,也支持原生Android App基于元素识别的UI自动化测试.主要包含了三部分:Airtest IDE. ...

  5. Poco的介绍和入门教学

    版权声明:该文章为AirtestProject原创文章:允许转载,但转载必须注明“转载”并保留原链接 前言 前面我们已经介绍了基于图像识别的测试框架Airtest,通过图像识别,已经可以编写大部分的测 ...

  6. 使用Airtest进行UI自动化测试

    一.环境搭建 1.Airtest客户端下载 访问官网http://airtest.netease.com/,根据自己的系统下载相应的客户端安装: 2.python工具下载与环境搭建 在本地python ...

  7. 如何在iOS手机上进行自动化测试

    版权声明:允许转载,但转载必须保留原链接:请勿用作商业或者非法用途 Airtest支持iOS自动化测试,在Mac上为iOS手机部署iOS-Tagent之后,就可以使用AirtestIDE连接设备,像连 ...

  8. airtest自动化中的poco+python连接手机实现ui自动化

    airtest:http://airtest.netease.com/docs/docs_AirtestIDE-zh_CN/index.html官网地址 AirtestIDE:跨平台的UI自动化测试编 ...

  9. Airtest,Poco,Unity自动化测试集成

    作为一个Game Developer,测试部分是必不可少,程序完成需求首先要进行S0相关的测试,这样确保交付到策划验收和QA验收时是没有阻断性的bug或者显而易见代码缺陷.那么如何去做测试用例呢?肯定 ...

随机推荐

  1. 一款 App 开发到上架

    随着互联网时代的发展,越来越多的 App 诞生啦.App 是手机软件的简称,手机主流的有 iOS.Andriod. 开发一个 App 需要哪些步骤呢?下面我和大家分享一下. 一.APP 的 idea( ...

  2. Asp 日期格式化问题 沙比作者,我改过来。

    Asp 日期格式化问题 投稿:mdxy-dxy 字体:[增加 减小] 类型:转载 时间:2009-06-14我要评论 asp做网站经常遇到日期格式处理问题,介绍一个有用的vbscript函数forma ...

  3. [BZOJ4916]神犇(Monster_Qi)和蒟蒻(SWHsz)

    很久很久以前,有一只神犇叫Monster_Qi; 很久很久之后,有一只蒟蒻叫SWHsz; 1<=N<=1E9,A.B模1E9+7; 求这个. 求μ的话直接输出1就行了因为除了1的平方外都有 ...

  4. [tyvj-1071]LCIS 动态规划

    LCIS模板 #include <cstdio> #include <cstring> #include <iostream> using namespace st ...

  5. iptables防火墙和selinux

    iptables 存在以下两种方式: 一.service方式 查看防火墙状态: [root@centos6 ~]# service iptables status iptables:未运行防火墙 开启 ...

  6. Centos文件查看命令字符

    文件(夹)查看类命令 ls--显示指定目录下内容 说明:ls 显示结果以不同的颜色来区分文件类别.蓝色代表目录,灰色代表普通文件,绿色代表可执行文件,红色代表压缩文件,浅蓝色代表链接文件. -a--- ...

  7. Sping面试题分析

    1.开放中主要使用Spring的什么技术? (1)IOC容器管理各层的组件 (2) 使用AOP配置声明式事务 (3)整合其他框架 2简述AOP和IOC概念 AOP : Aspect  Orienten ...

  8. 由free命令想到的

    root@xdj-Z9PA-D8-Series:~# free -m total used free shared buffers cached Mem: 15977 1683 14293 0 132 ...

  9. nyoj Wythoff Game(暴力枚举)

    Wythoff Game  ms |   KB 描写叙述 近期ZKC同学在学博弈,学到了一个伟大的博弈问题--威佐夫博弈. 相信大家都学过了吧?没学过?没问题.我将要为你讲述一下这个伟大的博弈问题. ...

  10. OpenCV+海康威视摄像头的实时读取

    OpenCV+海康威视摄像头的实时读取 本文由 @lonelyrains出品.转载请注明出处. 文章链接: http://blog.csdn.net/lonelyrains/article/detai ...