ide中也可以执行命令行,就是把用点击按钮运行时的log打印的启动命令重新输一下。这里不再讲(ps,这样还不如用ide的按钮运行。干嘛多次一举呢~~)
我们讲如何用本地python环境运行
准备环境:
- python环境,3.x的版本
- 安装airtest(pip3 install airtest)
- 安装poco(pip3 install pocoui)
运行脚本:
进入到对应的脚本目录,然后执行
python3 -m airtest run test1.air --device android://127.0.0.1:5037/TPG4C18308000271 --log log/
如果是连接了多个设备:python3 -m airtest run test1.air --device android://127.0.0.1:5037/TPG4C18308000271 --device android://127.0.0.1:5037/TPG4C18308000271 --log log/
脚本参数介绍:
【test1.air】是脚本的名称
【android://127.0.0.1:5037/TPG4C18308000271 】是设备号(在ide上运行的时候,log打印的那一串)
【log/】log的目录(相对test1.air的路径的)
当然除了 --device --log还有其他的一些参数,比如:--recording录屏等,具体用到看文档
生成报告:
airtest report test1.air --log_root log/ --outfile log/test1/test1_log.html --lang zh
脚本参数介绍:
--log_root log/表示用当前目录下,log/目录里面的log内容来生成了一个html报告;
--outfile log/test1/test1_log.html表示将这个html报告放在log目录下,命名为log.html;
--lang zh表示指定显示语言为中文。
三、扩展
3.1、放到python项目里面批量运行
只需要把在ide中编写脚本,复制一份到该项目文件的air_case目录下即可(注意要复制所有的代码不只是.air文件,还包括图片信息)
3.2、更多扩展内容看下一篇文档