# playwright-demo **Repository Path**: joyamon/playwright-demo ## Basic Information - **Project Name**: playwright-demo - **Description**: playwright-project基于微软开发的现代化Web自动化测试库Playwright开发的UI自动化测试项目。Swag Labs网站自动化测试框架用于playwright学习,涵盖了从环境搭建、测试开发到报告生成的完整流程。 - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-10 - **Last Updated**: 2025-12-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: UI自动化, playwright ## README # playwright-project playwright-project基于微软开发的**现代化Web自动化测试库**Playwright开发的UI自动化测试项目。Swag Labs网站自动化测试框架用于playwright学习,涵盖了从环境搭建、测试开发到报告生成的完整流程。 ### 项目特点 1. **企业级架构**:完整的项目结构和配置管理 2. **页面对象模型**:清晰的代码组织和复用 3. **灵活的配置**:支持多环境、多浏览器测试 4. **丰富的报告**:HTML报告、截图、视频录制 5. **持续集成友好**:支持并行执行和失败重试 ### 推荐版本 ``` playwright==1.44.0 pytest==7.4.4 pytest-playwright==0.4.3 pytest-xdist==3.5.0 pytest-html==4.1.1 pytest-rerunfailures==12.0 python-dotenv==1.0.0 allure-pytest==2.13.2 Faker==22.3.0 dotenv==0.9.9 pytest-html-report==1.0.6 ``` ### 项目结构 ``` playwright-project/ ├── fixtures/ │ ├── __init__.py │ └── test_data.py ├── pages/ │ ├── __init__.py │ ├── base_page.py │ ├── login_page.py │ ├── product_page.py ├── reports/ │ └── .gitkeep ├── screenshots/ │ └── .gitkeep ├── tests/ │ ├── __init__.py │ ├── test_login.py │ ├── test_product.py ├── utils/ │ ├── __init__.py │ └── helpers.py ├── config.py ├── conftest.py ├── pytest.ini ├── pytest_html_report.yml pytest-html-report 插件配置 └── README.md ├── requirements.txt ├── run_tests.py ``` ### 快速启动 ``` bash # 克隆项目后,进入项目目录 cd ecommerce-automation # 创建虚拟环境 python -m venv venv # 激活虚拟环境 # Windows: venv\Scripts\activate # macOS/Linux: source venv/bin/activate # 安装依赖 pip install -r requirements.txt # 安装浏览器 playwright install # 编辑 .env 文件配置你的测试环境 # 运行所有测试 # 运行登录测试 python run_tests.py --type=login # 显示浏览器界面运行 python run_tests.py --headed # 使用 Firefox 运行 python run_tests.py --browser=firefox # 并行运行测试 python run_tests.py --workers=4 ``` ### 效果截图 #### 测试报告 #### 查看allure 报告 使用 Allure 独立版本(不依赖 Node.js) 从 GitHub 下载 Allure 二进制包: 访问:https://github.com/allure-framework/allure2/releases 下载对应系统的 .zip 文件(如 Windows 下载 allure-2.xx.x.zip) 解压并配置环境变量: 将解压后的 bin 目录路径添加到系统环境变量 PATH 中 或者将 allure.bat 文件复制到已有环境变量的目录