Airtest网易自动化测试工具

一 使用目的该工具主要是面向游戏UI测试基于图像识别,如游戏框架unity,Cocos-js以及网易内部的游戏框架同时也支持原生Android App 的基于元素识别的UI自动化测试.本文主要使用目的是做安卓原生App的元素UI自动化.二 资源索引官方资源网易游戏新开源的 UI 自动化测试项目 [Airtest Project]Airtest官网Airtest官网上手教程Air...
摘要由CSDN通过智能技术生成

一 使用目的

该工具主要是面向游戏UI测试基于图像识别,如游戏框架unity,Cocos-js以及网易内部的游戏框架
同时也支持原生Android App 的基于元素识别的UI自动化测试.
本文主要使用目的是做安卓原生App的元素UI自动化.

二 资源索引

官方资源

网易游戏新开源的 UI 自动化测试项目 [Airtest Project]
Airtest官网
Airtest官网上手教程
AirtestProject Github主页
AirtestIDE官方中文文档
Airtest 官方中文文档
PocoUI自动化框架官方中文文档

Android App UI自动化相关API

airtest.core.api module
poco.drivers.android.uiautomation module

三 环境准备

Python3 开发环境部署

如果只想用AirtestIDE这款前端集大成的开发IDE工具通过,前端点点点生成或录制方式生成脚本的话,你完全可以开箱即用,完全不用搞以下Python开发环境.
如果想自己利用底层API扩展高级脚本框架,为了更便利的直接使用airtest 或 poco 的API,建议还是提前部署好Python3开发环境.

Python3.6.4
这里提供了许多种格式的安装包,如windows下常见的.exe格式.这种安装方便,大多数的选择.
找到你系统对应的安装包,我是win10 64位操作系统 选择的是python-3.6.4-amd64.exe
安装到我本地的D:盘D:\Python36\ 下
配置环境变量(请注意根据跟人习惯统一添加到用户变量还是系统变量,我个人一般全部添加到系统变量),追加到Path末尾,D:\Python36\;D:\Python36\Scripts\

笔者当前win10,是Python2和Python3共存的,如有需要具体部署请参考
Win10下python3和python2同时安装并解决pip共存问题

附上最终的一些版本检查与pip2 pip3部署检查命令

#Python2 检查
C:\Users\cmd>python2
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
#Python3检查
C:\Users\cmd>python3
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
#pip3部署
C:\Users\cmd>python3 -m pip install --upgrade pip --force-reinstall
Collecting pip
  Downloading pip-9.0.2-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 746kB/s
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
Successfully installed pip-9.0.2
#pip2部署
C:\Users\cmd>python2 -m pip install --upgrade pip --force-reinstall
Collecting pip
  Using cached pip-9.0.2-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
Successfully installed pip-9.0.2
#检查pip2
C:\Users\cmd>pip2 -V
pip 9.0.2 from d:\python27\lib\site-packages (python 2.7)
#检查pip3
C:\Users\cmd>pip3 -V
pip 9.0.2 from d:\python36\lib\site-packages (python 3.6)
#检查pip2 python2已安装库
C:\Users\cmd>pip2 list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
pip (9.0.2)
setuptools (28.8.0)
#检查pip3 python3已安装库
C:\Users\cmd>pip3 list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
pip (9.0.2)
setuptools (28.8.0)
#检查哪些python3库需要升级
C:\Users\cmd>pip3 list -o
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
setuptools (28.8.0) - Latest: 39.0.1 [wheel]
# 升级该库
C:\Users\cmd>pip3 install --upgrade setuptools
Collecting setuptools
  Downloading setuptools-39.0.1-py2.py3-none-any.whl (569kB)
    100% |████████████████████████████████| 573kB 815kB/s
Installing collected packages: setuptools
  Found existing installation: setuptools 28.8.0
    Uninstalling setuptools-28.8.0:
      Successfully uninstalled setuptools-28.8.0
Successfully installed setuptools-39.0.1

虚拟Python virtualenv环境部署

为什么要用virtualenv 虚拟环境,因为当你鼓捣Python开源项目多了的时候,比如自动化方向的selenium, Appium-Python-Client, ATX的uiautomator2的时候,如果放在一个Python环境下,用Pycharm找引用ctrl+B的时候,相似api方法名就会跳出多个,你就会不知道到底是引用的哪一个库下的,独立分开各个UI自动化Python虚拟环境的话,查起来就方便减少了迷惑.

#安装virtualenv
C:\Users\cmd>pip3 install virtualenv
Collecting virtualenv
  Using cached virtualenv-15.1.0-py2.py3-none-any.whl
Installing collected packages: virtualenv
Successfully installed virtualenv-15.1.0
#激活使用该virtualenv
C:\Users\cmd\venv\Scripts>activate.bat
#见到以下输出即成功
(venv) C:\Users\cmd\venv\Scripts>

如果想创建独立的Airtest Python3开发环境,可如下

#创建基于Python3.6.4的名为Airtest364的虚拟环境
C:\Users\cmd>virtualenv -p D:\Python36\python3.exe Airtest364
Running virtualenv with interpreter D:\Python36\python3.exe
Using base prefix 'D:\\Py
  • 0
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值