MCPcopy Index your code
hub / github.com/AirtestProject/Airtest

github.com/AirtestProject/Airtest @v1.4.3 sqlite

repository ↗ · DeepWiki ↗ · release v1.4.3 ↗
1,660 symbols 5,601 edges 138 files 679 documented · 41%
README

Airtest · Build status

跨平台的UI自动化框架,适用于游戏和App

image

快速开始

  • 各种运行: Airtest提供了跨平台的API,包括安装应用、模拟输入、断言等。 基于图像识别技术定位UI元素,你无需嵌入任何代码即可进行自动化。

  • 扩展性: Airtest提供了命令行和python接口,可以很容易地在大规模设备集群上运行。自动生成的HTML报告,包含详细步骤和录屏,让你迅速定位失败点。

  • AirtestIDE: 是一个强大的GUI工具,可以帮助你录制和调试自动化脚本。 AirtestIDE支持了完整的自动化流程:录制脚本->真机回放->生成报告

  • Poco: Poco 框架可以直接访问UI控件,支持主流平台和游戏引擎。通过Python API操作UI控件,可以实现更强大的自动化控制。

从官网开始上手吧

跨平台支持

安装

使用 pip 安装Airtest框架

pip install -U airtest

在Mac/Linux系统下,需要手动赋予adb可执行权限

# mac系统
cd {your_python_path}/site-packages/airtest/core/android/static/adb/mac
# linux系统
# cd {your_python_path}/site-packages/airtest/core/android/static/adb/linux
chmod +x adb

如果你需要使用GUI工具,请从 官网 下载AirtestIDE。

文档

完整的Airtest文档请看 readthedocs

例子

Airtest希望提供平台无关的API,让你的自动化代码可以运行在不同平台的应用上。

  1. 使用 connect_device 来连接任意Android设备或者Windows窗口。
  2. 使用 模拟操作 的API来自动化你的游戏或者App。
  3. 不要 忘记 声明断言 来验证结果。
from airtest.core.api import *

# 通过ADB连接本地Android设备
init_device("Android")
# 或者使用connect_device函数
# connect_device("Android:///")
connect_device("Android:///")
install("path/to/your/apk")
start_app("package_name_of_your_apk")
touch(Template("image_of_a_button.png"))
swipe(Template("slide_start.png"), Template("slide_end.png"))
assert_exists(Template("success.png"))
keyevent("BACK")
home()
uninstall("package_name_of_your_apk")

更详细的说明请看 Airtest Python API 文档 或者直接看 API代码

用命令行运行 .air 脚本

使用AirtestIDE你可以非常轻松地录制一个自动化脚本并保存为 .air 目录结构。 Airtest命令行则让你能够脱离IDE,在不同宿主机器和被测设备上运行自动化脚本。

# 在本地ADB连接的安卓手机上运行脚本
airtest run "path to your air dir" --device Android:///

# 在Windows应用上运行脚本
airtest run "path to your air dir" --device "Windows:///?title_re=Unity.*"

# 生成HTML报告
airtest report "path to your air dir"

# 也可以用python -m的方式使用命令行
python -m airtest run "path to your air dir" --device Android:///

试试样例airtest/playground/test_blackjack.air,更多用法看命令行用法

贡献代码

欢迎大家fork和提pull requests。

致谢

感谢以下仓库让Airtest变得更好:

关于我们

访问我们的官网获得更多信息,同时欢迎大家扫描下方二维码关注我们的微信公众号:AirtestProject

image

Core symbols most depended-on inside this repo

get
called by 110
airtest/utils/selenium_proxy.py
push
called by 83
airtest/core/ios/ios.py
shell
called by 70
airtest/core/android/adb.py
read
called by 39
airtest/utils/apkparser/bytecode.py
get_logger
called by 33
airtest/utils/logger.py
get_value
called by 27
airtest/utils/apkparser/bytecode.py
cmd
called by 27
airtest/core/android/adb.py
list_app
called by 26
airtest/core/ios/ios.py

Shape

Method 1,105
Function 380
Class 169
Route 6

Languages

Python92%
TypeScript8%

Modules by API surface

airtest/core/android/adb.py81 symbols
airtest/report/js/jquery-1.10.2.min.js74 symbols
airtest/core/ios/ios.py74 symbols
tests/test_ios.py65 symbols
airtest/core/android/android.py55 symbols
airtest/utils/apkparser/bytecode.py47 symbols
airtest/core/win/win.py41 symbols
tests/test_android.py40 symbols
airtest/core/android/touch_methods/base_touch.py36 symbols
tests/test_adb.py33 symbols
airtest/report/report.py31 symbols
airtest/report/js/highlight.min.js30 symbols

Dependencies from manifests, versioned

Jinja22.8 · 1×
Pillow3.4.0 · 1×
facebook-wda1.5.0 · 1×
mss6.1.0 · 1×
opencv-contrib-python4.4.0.46 · 1×
pywinauto0.6.3 · 1×
requests2.11.1 · 1×
six1.9.0 · 1×
sphinx-markdown-tables0.0.15 · 1×

For agents

$ claude mcp add Airtest \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact