Airtest-GUI 开源项目教程
airtest-guiGUI write by qt for airtest项目地址:https://gitcode.com/gh_mirrors/ai/airtest-gui
项目介绍
Airtest-GUI 是由 NetEase 开发的一个基于 Qt 的图形用户界面,用于 Airtest 项目。Airtest 是一个跨平台的 UI 自动化测试框架,支持游戏和应用程序的自动化测试。Airtest-GUI 提供了一个直观的界面,使得用户可以轻松地编写、运行和管理自动化测试脚本。
项目快速启动
安装
-
克隆项目仓库:
git clone https://github.com/NetEase/airtest-gui.git
-
安装依赖:
pip install -r requirements.txt
-
运行 Airtest-GUI:
python airtest-gui.py
编写第一个测试脚本
-
打开 Airtest-GUI:
python airtest-gui.py
-
创建新项目:
- 点击“新建项目”,输入项目名称和保存路径。
-
编写测试脚本:
from airtest.core.api import * auto_setup(__file__) touch(Template("path/to/image.png")) assert_exists(Template("path/to/expected_image.png"), "检查预期图像存在")
-
运行测试脚本:
- 点击“运行”按钮,Airtest-GUI 将自动执行脚本并生成测试报告。
应用案例和最佳实践
游戏自动化测试
Airtest 支持所有游戏引擎,通过图像识别和 UI 层次结构,可以轻松实现游戏自动化测试。例如,测试一个点击按钮的功能:
touch(Template("path/to/button_image.png"))
assert_exists(Template("path/to/button_clicked_image.png"), "检查按钮点击后的状态")
跨平台应用测试
Airtest 支持 Windows、Android 和 iOS 平台,通过编写一次代码,可以在多个平台上运行测试脚本。例如,测试一个跨平台的登录功能:
touch(Template("path/to/login_button.png"))
assert_exists(Template("path/to/login_success_image.png"), "检查登录成功后的状态")
典型生态项目
Poco
Poco 是一个 UI 自动化框架,与 Airtest 结合使用,可以轻松访问 iOS 和 Android 的本地元素,并获取它们的位置和属性。例如,测试一个文本框的输入:
poco("text_input").set_text("Hello, Airtest!")
assert_equal(poco("text_input").get_text(), "Hello, Airtest!", "检查文本框内容")
Selenium Plugin
基于 Chrome Devtools Protocol,Airtest 提供了 Selenium 插件,可以准确地记录和生成 Selenium 脚本,访问网页元素。例如,测试一个网页按钮的点击:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://example.com")
driver.find_element_by_id("button_id").click()
assert "Button Clicked" in driver.page_source
driver.quit()
通过这些模块的介绍和示例,您可以快速上手 Airtest-GUI 项目,并利用其强大的功能进行跨平台的 UI 自动化测试。
airtest-guiGUI write by qt for airtest项目地址:https://gitcode.com/gh_mirrors/ai/airtest-gui
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考