# Playwright实现基于python的UI自动化框架 **Repository Path**: wgldream/vss_playwright_ui_test ## Basic Information - **Project Name**: Playwright实现基于python的UI自动化框架 - **Description**: 基于python+pytest+playwright+allure实现的UI自动化测试框架, 日志&测试步骤 报告&失败截图 配置文件&数据源设计 公共函数&API封装 测试数据&参数化、解耦 测试套件&测试用例设计、组装 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 4 - **Created**: 2025-11-28 - **Last Updated**: 2025-11-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # VSS Playwright UI 测试项目 这是一个基于 Playwright 的 UI 自动化测试项目,用于测试 VSS 相关功能。项目使用了 Page Object Model 设计模式,并集成了 Allure 报告框架。 ## 📁 项目结构 ``` . ├── BasePage/ # 基础页面类,封装了常用的页面操作方法 ├── BuildinLibrary/ # 内置库,提供参数替换等功能 ├── Common/ # 公共模块,包含 Allure 报告美化工具 ├── Config/ # 配置模块,包含项目配置信息 ├── Pages/ # 页面对象目录,每个页面对应一个类 ├── TestCase/ # 测试用例目录,包含具体的测试脚本 ├── TestDatas/ # 测试数据目录,使用 YAML 文件存储测试数据 ├── TestReport/ # 测试报告输出目录 ├── Utils/ # 工具类目录,包含 YAML 文件读取工具 ├── conftest.py # pytest 固定装置配置文件 ├── requirements.txt # 项目依赖文件 └── run.py # 测试执行入口文件 ``` ## 🛠️ 技术栈 - [Playwright](https://playwright.dev/) - 浏览器自动化工具 - [pytest](https://docs.pytest.org/en/latest/) - 测试框架 - [Allure](https://docs.qameta.io/allure/) - 测试报告框架 - [YAML](https://yaml.org/) - 测试数据存储格式 ## 📦 安装 1. 安装依赖 ```bash pip install -r requirements.txt ``` 2. 安装 Playwright 浏览器 ```bash playwright install ``` ## 🧪 使用方法 1. 编写测试用例 测试用例位于 `TestCase` 目录下,使用 `pytest` 框架编写。 2. 运行测试 ```bash python run.py ``` 3. 查看测试报告 测试报告生成在 `TestReport/AllureReport` 目录下,可以使用以下命令启动报告服务器: ```bash allure serve TestReport/AllureResult ``` ## 📝 页面对象模式 项目采用 Page Object Model 设计模式,每个页面对应一个类,封装了该页面的元素定位和操作方法。例如: ```python class LoginPage(BasePage): def goto_login(self, url): self._goto_url(url) def fill_username(self, value): self._fill("#username", value) def fill_password(self, value): self._fill("#password", value) def click_login_button(self): self._click("#login-button") ``` ## 📊 测试数据 测试数据使用 YAML 格式存储在 `TestDatas` 目录下,通过 `ReadYaml` 工具类读取。 ```yaml - username: "testuser" password: "testpass" expected_result: "success" ``` ## 📎 Allure 报告 测试结果会生成 Allure 报告,包含详细的测试步骤、截图和执行信息。报告生成在 `TestReport/AllureResult` 目录下。 ## 📤 贡献指南 欢迎贡献代码!请遵循以下步骤: 1. Fork 项目 2. 创建新分支 (`git checkout -b feature/new-feature`) 3. 提交更改 (`git commit -am 'Add new feature'`) 4. 推送分支 (`git push origin feature/new-feature`) 5. 创建 Pull Request ## 📄 许可证 本项目使用 MIT 许可证,请查看 [LICENSE](LICENSE) 文件了解详细信息。