The Example Testing Framework is a robust and scalable automation framework designed for UI and API testing. It leverages Playwright for browser automation and APIRequestContext for API testing, enabling comprehensive end-to-end test coverage. The framework is built for maintainability, reusability, and test isolation, making it ideal for dynamic, large-scale applications.
- Implements the POM design pattern for UI automation.
- Separates test logic from UI interactions, improving maintainability.
- Provides reusable components for interacting with pages such as:
LoginPageCatalogPageCartPageCheckoutPage
- Integrates API testing using Playwright's
APIRequestContext. - Includes an
PetsApiClientfor interacting with the Petstore API:- Create, update, and validate pets.
- Find pets by status or other attributes.
- Validate API responses using Pydantic models for strict type-checking and data validation.
- Uses a centralized
Configclass powered by Pydantic for managing configurations:- Dynamic URLs for different environments.
- Credentials and other static data.
- Supports environment-based configurations through JSON files (e.g.,
config_dev.json). - Easily extendable to add more configurations for future needs.
- Automatically resets browser context and state between tests to ensure test isolation.
- Leverages Playwright’s built-in fixtures for managing context and page lifecycle.
- Simplifies test setup with reusable fixtures.
- Fresh browser contexts and pages for each test.
- Centralized pre-test setup, including:
- Automatic login.
- Cart clearance to ensure consistent starting state for tests.
- Supports logging for debugging and reporting:
- API request and response details.
- Test outcomes and critical assertions.
- Integrates Playwright's trace and screenshot capabilities for debugging failed tests.
- Leverages Playwright’s parallel execution support for faster test runs.
- Ensures no state leakage between tests.
- Combines UI and API testing workflows for seamless end-to-end validation.
- Example: Create a pet via API, verify it appears in the UI, and complete an order.
- Python Version:
3.11.5 - Create a Python virtual environment and install the required dependencies.
-
Clone the repository to your local machine:
git clone <repository_url> cd <repository_folder>
-
Create a Python virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install the dependencies:
pip install -r requirements.txt playwright install
-
Run the UI tests using
pytest:pytest -v tests/test_catalog.py
-
Output:
- A test report will be generated in the
reportsfolder. - A Playwright
debug.zipfile will be available in thetest-resultsfolder for detailed debugging.
- A test report will be generated in the
-
Playwright Debugging Documentation:
-
Run the Backend Api tests using
pytest:pytest -v test_pets.py
This project is licensed under the MIT License. See the LICENSE file for details.