# 电商 demo 网页的UI自动化测试 **Repository Path**: Lewis3/ui_autotest ## Basic Information - **Project Name**: 电商 demo 网页的UI自动化测试 - **Description**: 基于Pytest+Playwright+Allure,采用 YAML 进行数据驱动,Loggin 模块进行日志输出,对电商demo网页saucedemo.com进行UI自动化测试。 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2026-07-24 - **Last Updated**: 2026-09-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: autotest ## README # UI Automation Testing Project This project is a UI automation testing framework built on **Playwright** and **pytest**, organized using the **Page Object Model (POM)** design pattern. ## Main Features This project is used for end-to-end testing of web applications, primarily covering the following business modules: * **Login Module**: Test user login, failure scenarios, input validation, etc. * **Product List Module**: Test product display, product sorting, add/remove from cart, etc. * **Shopping Cart Module**: Test CRUD logic for shopping cart items. * **Order Module**: Test the complete shopping process, including entering information, order confirmation, canceling orders, etc. ## Technology Stack * **Programming Language**: Python * **Testing Framework**: pytest * **Browser Automation**: Playwright * **Test Report**: Allure * **Configuration Management**: PyYAML ## Project Structure ```text . ├── common/ # Common utility classes │ ├── logger.py # Logger │ └── screenshot.py # Screenshot tool ├── config/ # Configuration files │ ├── __init__.py │ ├── config.py # Configuration loading logic │ └── config.yaml # Configuration file ├── pages/ # Page Object models │ ├── base_page.py # Base page class │ ├── login_page.py # Login page object │ ├── products_page.py # Product list page object │ ├── cart_page.py # Shopping cart page object │ └── order_page.py # Order process page object ├── test_cases/ # Test cases │ ├── test_login.py │ ├── test_products.py │ ├── test_cart.py │ └── test_order.py ├── conftest.py # pytest fixtures ├── pytest.ini # pytest configuration └── requirements.txt # Dependency list ``` ## Quick Start ### 1. Environment Setup Ensure Python is installed (version 3.8+ recommended). ### 2. Install Dependencies Execute the following command in the project root directory to install Python dependencies: ```bash pip install -r requirements.txt ``` ### 3. Install Browsers Install the browser environment required by Playwright: ```bash playwright install ``` ### 4. Run Tests Execute all test cases: ```bash pytest ``` ### 5. View Test Reports This project integrates Allure reports. The steps to generate and view the report are as follows: 1. **Generate Report Data**: ```bash pytest --alluredir=allure-results ``` 2. **Start Allure Service**: ```bash allure serve allure-results ``` ## Configuration Instructions Before running the project, please ensure that the configuration in `config/config.yaml` (such as base URL, test accounts, etc.) is set correctly.