A scalable, maintainable, and extensible test automation framework built using Python, Selenium WebDriver, PyTest, and Requests.
The framework supports both UI Automation and API Automation, follows the Page Object Model (POM) design pattern, and includes centralized configuration management, screenshot capture, Allure reporting, environment-based execution, and reusable utilities.
| Component | Technology |
|---|---|
| Language | Python 3 |
| UI Automation | Selenium WebDriver |
| API Automation | Requests |
| Test Framework | PyTest |
| Reporting | Allure Reports |
| Parallel Execution | pytest-xdist |
| Retry Mechanism | pytest-rerunfailures |
| Configuration | YAML + Environment Variables |
| Test Data | JSON |
| Design Pattern | Page Object Model (POM) |
| CI/CD | Jenkins / GitHub Actions |
project-root
│
├── api/
│ ├── events.py
│ └── ticket_booking.py
│
├── config/
│ ├── config_manager.py
│ └── qa.yaml
│
├── core/
│ ├── api_client.py
│ ├── auth_manager.py
│ ├── driver_manager.py
│ └── retry_handler.py
│
├── exceptions/
│ └── custom_exceptions.py
│
├── pages/
│ ├── base_page/
│ └── form_page/
│
├── test_data/
│ ├── event_data.json
│ └── bookings_data.json
│
├── tests/
│ ├── api_test/
│ └── ui_test/
│
├── utils/
│ ├── screenshot_utils.py
│ ├── logger.py
│ ├── json_reader.py
│ └── date_utils.py
│
├── conftest.py
├── requirements.txt
└── README.md
| Design Decision | Implementation | Benefit |
|---|---|---|
| Page Object Model | Base Page + Feature Pages | Easier maintenance and reusable actions |
| Configuration Management | YAML-based environment configuration | Easy environment switching |
| Screenshot Capture | Automatic screenshot on test failures | Faster debugging |
| API Layer Separation | Dedicated API modules | Cleaner test implementation |
| Reusable Driver Factory | DriverManager | Centralized browser management |
| JSON Test Data | Externalized test data files | Better test maintainability |
| Allure Reporting | Integrated with PyTest hooks | Rich execution reports |
| Retry Support | pytest-rerunfailures | Handles flaky tests |
- Selenium WebDriver
- Page Object Model (POM)
- Reusable page actions
- Cross-browser execution
- Headless execution support
- Automatic screenshot capture on failures
- REST API testing using Requests
- Reusable API client layer
- Authentication management
- Request and response validation
- Environment-based configuration
- Centralized logging
- JSON test data management
- Custom exception handling
- Retry mechanism
- Parallel execution
- Chrome
- Firefox
Browser configuration is managed through environment-specific YAML files.
git clone <repository-url>
cd Selenium-Pytest-Automation-FrameworkWindows
python -m venv venv
venv\Scripts\activateLinux / Mac
python3 -m venv venv
source venv/bin/activatepip install -r requirements.txtpytest
selenium
allure-pytest
pytest-xdist
pytest-rerunfailures
requests
pyyaml
python-dotenv
pytestpytest tests/ui_test -vpytest tests/api_test -vpytest --env=qapytest -n autopytest --reruns 2pytest -vGenerate Allure Results
pytest --alluredir=reports/allure-resultsGenerate Report
allure generate reports/allure-results --cleanOpen Report
allure serve reports/allure-results- Form validation
- Input field validation
- User interaction workflows
- End-to-end UI scenarios
- Create Event
- Retrieve Event
- Update Event
- Delete Event
- Create Booking
- Retrieve Booking
- Update Booking
- Cancel Booking
Environment-specific configurations are maintained in YAML files.
Example:
browser: chrome
headless: false
base_url: https://example.comRun using:
pytest --env=qaThe framework provides:
- Allure Reports
- Failure Screenshots
- Execution Logs
- Request/Response Validation
- Detailed Assertion Messages
The framework can be integrated with:
- Jenkins
- GitHub Actions
- GitLab CI/CD
- Azure DevOps
Pipeline capabilities include:
- Automated execution
- Scheduled runs
- Allure report generation
- Artifact publishing
- Failure notifications
- Page Object Model (POM)
- Reusable Components
- Environment-Based Configuration
- Externalized Test Data
- Separation of Concerns
- API/UI Layer Isolation
- Screenshot Capture on Failure
- Rich Reporting
- CI/CD Friendly Design
Santhosh S
Senior QA Engineer | Test Automation | API Testing | Selenium | PyTest