A simple UI automation framework built using Selenium WebDriver, Python, and PyTest following the Page Object Model (POM) design pattern.
The goal of this project is to demonstrate how a maintainable and scalable test automation framework can be structured while supporting data-driven testing, reusable utilities, logging, and reporting.
This repository was built as a practice project to simulate how UI automation frameworks are commonly organized in real QA environments.
- Selenium WebDriver automation
- PyTest test runner
- Page Object Model (POM)
- Data-driven testing using JSON
- Config-based environment setup
- Screenshot capture on test failure
- HTML test reports
- Logging for test execution
- Retry mechanism for flaky tests
- Python
- Selenium
- PyTest
- pytest-html
- webdriver-manager
selenium-python-pytest-framework
│
├── tests
│ └── test_login.py
│
├── pages
│ └── login_page.py
│
├── utilities
│ ├── base_class.py
│ ├── config_reader.py
│ ├── data_reader.py
│ ├── driver_factory.py
│ ├── logger.py
│ └── screenshot.py
│
├── data
│ └── login_test_data.json
│
├── config
│ └── config.json
│
├── logs
│
├── screenshots
│
├── reports
│
├── conftest.py
├── pytest.ini
├── requirements.txt
└── README.md
The framework is organized into several layers to keep the code modular and maintainable.
tests/
Contains the test scenarios written using PyTest. Tests validate application behavior using assertions and test data.
pages/
Implements the Page Object Model where each page contains:
- locators
- page actions
- interaction logic
This helps keep test cases clean and reduces duplication.
utilities/
Reusable helper modules used across the framework.
Examples include:
- driver_factory – initializes WebDriver
- config_reader – loads configuration values
- data_reader – loads test data
- logger – handles framework logging
- screenshot – captures screenshots when tests fail
data/
Test data is stored in JSON format to support data-driven testing.
Example:
{
"username": "tomsmith",
"password": "SuperSecretPassword!",
"expected": "success"
}
config/
Configuration values such as:
- base URL
- browser type
- wait time
are stored here to avoid hardcoding values throughout the code.
Clone the repository:
git clone https://github.com/CypherMorgan/selenium-python-pytest-framework.git
Navigate into the project directory:
cd selenium-python-pytest-framework
Install dependencies:
pip install -r requirements.txt
Run the tests:
pytest
After execution, an HTML report is generated inside the reports folder.
Example:
reports/report.html
The report includes:
- test results
- execution duration
- failure details
- screenshots for failed tests
If a test fails, the framework automatically captures a screenshot.
Screenshots are saved inside:
screenshots/
This helps with debugging and understanding test failures.
The framework currently includes a login test using a public demo site.
The following scenarios are covered:
- valid login
- invalid credentials
- empty username
Each test is executed using PyTest parametrization with data loaded from JSON.
pytest starts
↓
test data loaded from JSON
↓
browser launched via WebDriver
↓
page object interacts with UI
↓
assertions validate expected result
↓
logs and screenshots captured
↓
HTML report generated
Possible improvements that could be added:
- parallel test execution
- CI/CD integration
- Allure reporting
- environment switching (dev / staging / prod)
- API test support
Created as a practice project to explore building a structured Selenium test automation framework using Python and PyTest.