ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

Airtest IDE 自动化测试16 - 本地 python3 环境命令运行 airtest 脚本

2022-08-29 12:00:11  阅读:153  来源: 互联网

标签:AirtestIDE log 16 -- Airtest Administrator airtest Users


前言

Airtest IDE 自带了 python3 环境,但是每次执行脚本都需要打开IDE,在IDE 上点运行按钮才能执行。

如果我们想通过命令行执行脚本,可以在本机安装python3

环境准备

安装python3 环境 和pip,这个不多说,我用的python3.7环境

1 2 3 4 5 C:\Users\Administrator>python Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 201804:59:51) [MSC v.1914 64 bit (AMD6 4)] on win32 Type "help""copyright""credits" or "license" for more information. >>> 

pip 安装 Airtest 库

1 2 C:\Users\Administrator>pip install airtest --index-url https://pypi.douban.com/s imple

  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 C:\Users\Administrator>pip show airtest Name: airtest Version: 1.1.11 Summary: UI Test Automation Framework for Games and Apps on Android/iOS/Windows/ Linux Home-page: https://github.com/AirtestProject/Airtest Author: Netease Games Author-email: gzliuxin@corp.netease.com License: Apache License 2.0 Location: c:\users\administrator\appdata\local\programs\python\python37\lib\site -packages Requires: Jinja2, Pillow, requests, six, mss, numpy, opencv-contrib-python, face book-wda, pywinauto, pywin32 Required-by:   C:\Users\Administrator>

 pip 安装 poco 框架,库名是 pocoui

1 2 C:\Users\Administrator>pip install pocoui --index-url https://pypi.douban.com/si mple

 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 C:\Users\Administrator>pip show pocoui Name: pocoui Version: 1.0.84 Summary: Poco cross-engine UI automated test framework. Home-page: https://github.com/AirtestProject/Poco Author: Netease Games Author-email: lxn3032@corp.netease.com, gzliuxin@corp.netease.com License: Apache License 2.0 Location: c:\users\administrator\appdata\local\programs\python\python37\lib\site -packages Requires: six, requests, airtest, hrpc, websocket-client Required-by:   C:\Users\Administrator>

 安装了airtest 和pocoui 后就可以不用 AirtestIDE,自己写python脚本,运行脚本了。

命令行参数

AirtestIDE 上运行脚本后,查看日志

1 "D:\tools\AirtestIDE-win-1.2.12\AirtestIDE\AirtestIDE" runner "D:\study\airtest2021\a01.air"  --device android://127.0.0.1:5037/emulator-5554?cap_method=MINICAP&&ori_method=MINICAPORI&&touch_method=MINITOUCH --log "C:\Users\Administrator\AppData\Local\Temp\AirtestIDE\scripts\7a193bbe7d3636ce98d92de5104a7d6e" 

 

 运行可以知道运行脚本的命令格式

1 AirtestIDE runner 脚本.air --device android://127.0.0.1:5037/emulator-5554(手机设备) --log 指定日志保存路径

 参数说明:

  • AirtestIDE AirtestIDE 执行命令行工具
  • runner 需运行的脚本,后面参数指定脚本地址,格式是*.air 目录的格式
  • --device host 是adb server 所在主机的ip,默认是本机127.0.0.1,adb port默认是5037,后面是android手机的序列号,adb device查看到的
  • --log 指定日志保存路径

 本地 python3 安装完airtest 库后,可以用airtest 命令代替 AirtestIDE,run 指令代替 runner.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 C:\Users\Administrator>airtest usage: airtest [-h] {version,run,info,report} ...   positional arguments:   {version,run,info,report}                         version/run/info/report     version             show version and exit     run                 run script     info                get & print author/title/desc info of script     report              generate report of script   optional arguments:   -h, --help            show this help message and exit   C:\Users\Administrator>

 运行.air 脚本

运行脚本和生成 html 报告是2个步骤,cd到脚本所在目录  

run 运行脚本

1 2 D:\study\airtest2021>airtest run a01.air --device android://127.0.0.1:5037/emula tor-5554 --log ./log

 运行完成后,在当前脚本目录会生成一个log文件夹,log.txt 记录测试运行结果

 

 

 生成 html 报告

生成测试报告 report 命令

1 2 D:\study\airtest2021>airtest report a01.air --log_root ./log --outfile ./log/log .html --lang zh

 参数说明:

report 指定运行脚本生成报告

--log_root 指定log文件命令

--outfile 指定log.html 文件存放地方

--lang zh 是报告显示中文

查看报告

 

 

标签:AirtestIDE,log,16,--,Airtest,Administrator,airtest,Users
来源: https://www.cnblogs.com/louis-w/p/16635479.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有