This repository contains a UI automation suite developed to validate the functionality of the e-commerce website SauceDemo. The project demonstrates modern test automation practices, including Behavior-Driven Development (BDD), Page Object Model (POM), and CI/CD pipelines.
The goal of this project is to showcase:
- Test automation capabilities.
- Framework setup, structure, and scalability.
- Integration with tools like reporting, CI/CD pipelines, and pre-commit hooks.
This automation suite validates critical functionalities of the SauceDemo website:
-
Authentication
- Login and logout functionalities.
- Handling invalid credentials and missing input scenarios.
- Addressing performance issues, such as long login times.
-
Products Page
- Verification of product listings and navigation.
- Sorting products by name and price.
- Adding/removing products to/from the cart.
- Viewing product details.
-
Shopping Cart
- Validating the initial state of an empty cart.
- Adding/removing products and continuing shopping.
- Verifying cart updates and navigation functionality.
-
Checkout Process
- Ensuring mandatory fields are required.
- Validating initial and canceled states at each stage of checkout.
- Providing an overview of selected products before purchase.
-
Burger Menu
- Validating navigation options such as logout, "All Items," and "About."
- Handling the menu in different contexts, e.g., cart and checkout pages.
- Ensuring state reset functionality works as intended.
The project is organized with a clear folder structure to ensure scalability and maintainability:
ecommerce-ui-automation/
├── .github/ # GitHub Actions for CI/CD
│ └── workflows/
│ └── run_ui_tests.yml # Workflow configuration for CI pipeline
├── .pytest_cache/ # Pytest's cache directory (auto-generated, git-ignored)
├── ui_automation_suite/ # Python package for the test automation suite
│ ├── bdd_tests/ # Test scripts written in BDD style
│ │ ├── features/ # Gherkin feature files
│ │ ├── step_defs/ # Step definitions for test steps
│ │ ├── pytest_fixtures/ # Custom fixtures for Playwright and other utilities
│ │ └── page_objects/ # Page Object Models for web pages
│ ├── settings/ # Test configuration files
│ ├── utils/ # Utility functions and helpers
│ └── __init__.py # Marks this as a Python package
├── reports/ # Test execution reports (generated by Allure and Playwright traces)
│ ├── allure-report-bdd/ # Generated Allure HTML reports
│ ├── allure-results-bdd/ # Raw results for Allure
│ └── playwright_trace_data/ # Trace data generated by Playwright
├── .env # Environment variables (git-ignored)
├── .gitignore # Excludes unnecessary files from version control
├── .pre-commit-config.yaml # Pre-commit hooks for code quality checks
├── conftest.py # Pytest's configuration and shared fixtures
├── Makefile # Automation commands for setup and execution
├── pyproject.toml # Poetry configuration for dependencies
├── pytest.ini # Pytest configuration
├── README.md # Project documentation
└── poetry.lock # Poetry's lock file for dependencies
The suite is built using the following technologies:
- Test Automation Framework: Playwright
- BDD Framework: pytest-bdd
- Reporting: Allure
- Dependency Management: Poetry
- CI/CD: GitHub Actions
- Code Quality: pre-commit hooks (
black
,isort
) for linting and formatting - Logging: Python logging for debugging insights
The test suite is integrated with GitHub Actions for Continuous Integration (CI).
- Trigger CI Tests:
- automatically on pull requests
- manually via GitHub Actions Workflows
- View Results:
- [Github Pages]:
- an Allure report is automatically generated and hosted here.
⚠️ Note: Only the latest execution's report will be displayed️
- [Github Artifacts]:
- the Allure report is also stored as an artifact in the respective GitHub Actions run. You can download and view the report locally.
- [Github Pages]:
- Python 3.11 or later installed.
- Poetry installed (for dependency management).
- Clone the repository:
git clone https://github.com/yourusername/ecommerce-ui-automation.git cd ecommerce-ui-automation
- Install dependencies:
poetry install
- Run the complete test suite:
make test
- View the report:
make generate-and-view-report
- Click on the link to view the report in the browser
The test suite offers various execution modes for flexibility.
-
Run the complete test regression suite
- Headless Mode
make test
- Headed Mode
make test-headed
- Headless Mode
-
Run a specific test:
- Headless Mode
make test "MARKER=login_success"
- Headed Mode
make test-headed "MARKER=login_success"
- Headless Mode
-
Change Browser (default: chromium)
- Headless Mode
make test "BROWSER=firefox"
- Headed Mode
make test-headed "BROWSER=firefox"
- Headless Mode
-
Debug Mode (Runs only in headed mode)
- Run step-by-step:
make test-debug
- Combine with specific marker and browser:
make test-debug "MARKER=login_success" "BROWSER=firefox"
- Run step-by-step:
- Comprehensive Coverage: Validates authentication, product navigation, checkout, and more.
- Clean Architecture: Follows BDD principles, Page Object Models, and modular design.
- Continuous Integration: Automates test execution via GitHub Actions.
- Enhanced Reporting: Uses Allure for detailed test result visualizations.
- Pre-commit Hooks: Ensures code quality with tools like
black
andisort
.
- Integrate Visual Testing: Automate visual regression testing to detect UI inconsistencies and layout shifts effectively.
- Extend Test Coverage: Add more test scenarios for edge cases and negative paths.
- Parallelize Test Execution Across Browsers: Optimize test runtime by running tests simultaneously in multiple browsers (e.g., Chrome, Firefox, Safari).
- Automate Local Report Management: Implement a local mechanism to keep only the latest test report for easy access while automatically deleting older reports to reduce clutter.
- Centralize Report Storage for Historical Analysis: Implement a system to upload and store test results in a centralized location (e.g., S3 bucket, database, or CI tool dashboard) to maintain a history of test executions, allowing trend analysis and debugging over time.
- Cross-Device Testing: Extend test suite to simulate and verify functionality across different device types (e.g. mobile, tablet)
- Standardized Assertion Library: Create a dedicated and reusable library for assertion comparisons to promote consistency, maintainability, and readability across tests.