A production-ready Selenium Automation Framework built with Python, Pytest, and the Page Object Model (POM). The framework is designed to be scalable, maintainable, and CI/CD-ready, supporting cross-browser execution, environment-based configuration, automatic screenshots on failure, logging, and HTML reporting.
- ✅ Selenium 4
- ✅ Python 3
- ✅ Pytest Test Framework
- ✅ Page Object Model (POM)
- ✅ Cross Browser Testing
- Chrome
- Firefox
- Edge
- ✅ Headless Execution
- ✅ Environment Variable Configuration (.env)
- ✅ Automatic WebDriver Management
- ✅ HTML Test Reports
- ✅ Screenshots on Test Failure
- ✅ Logging
- ✅ GitHub Actions CI/CD Integration
- ✅ Clean Project Structure
- ✅ Easy to Extend
Tests
│
▼
Page Objects
│
▼
Driver Factory
│
▼
Selenium WebDriver
│
▼
Browser
SauceDemo-Selenium-Python-Framework
│
├── config/
│ ├── config.py
│ └── credentials.py
│
├── pages/
│ ├── login_page.py
│ ├── inventory_page.py
│ ├── cart_page.py
│ └── checkout_page.py
│
├── tests/
│ ├── test_login.py
│ ├── test_inventory.py
│ ├── test_cart.py
│ └── test_checkout.py
│
├── test_data/
│
├── utilities/
│ ├── driver_factory.py
│ ├── logger.py
│ ├── screenshot.py
│ └── excel_reader.py
│
├── logs/
├── reports/
├── screenshots/
│
├── .github/
│ └── workflows/
│ └── selenium.yml
│
├── conftest.py
├── pytest.ini
├── requirements.txt
├── .gitignore
└── README.md
| Technology | Purpose |
|---|---|
| Python | Programming Language |
| Selenium | Browser Automation |
| Pytest | Test Framework |
| webdriver-manager | Driver Management |
| python-dotenv | Environment Variables |
| pytest-html | HTML Reporting |
| GitHub Actions | Continuous Integration |
Clone the repository
git clone https://github.com/hassnain11/SauceDemo-Selenium-Python-Framework.gitNavigate to the project
cd SauceDemo-Selenium-Python-FrameworkCreate a virtual environment
python -m venv venvActivate the virtual environment
venv\Scripts\activatesource venv/bin/activateInstall dependencies
pip install -r requirements.txtCreate a .env file in the project root.
Example:
BASE_URL=https://www.saucedemo.com/
BROWSER=chrome
HEADLESS=False
IMPLICIT_WAIT=10Run all tests
pytestRun a specific test
pytest tests/test_login.pyRun tests in headless mode
pytest(Set HEADLESS=True in the .env file.)
Run using Firefox
BROWSER=firefoxRun using Edge
BROWSER=edgepytest --html=reports/report.html --self-contained-htmlOpen
reports/report.html
to view the report.
Whenever a test fails, the framework automatically captures a screenshot and saves it inside the screenshots/ directory.
This helps in quickly identifying UI failures during execution.
The framework logs important execution details including:
- Browser initialization
- Test execution
- Navigation
- Failures
- Screenshot paths
Logs are stored inside the logs/ directory.
Supported browsers:
- Google Chrome
- Mozilla Firefox
- Microsoft Edge
Browser selection is managed through the .env configuration.
GitHub Actions automatically:
- Installs project dependencies
- Starts the browser in headless mode
- Executes all test cases
- Generates execution reports
This ensures every push is automatically validated.
- Page Object Model
- Driver Factory Pattern
- Environment-based Configuration
- Cross Browser Testing
- Headless Execution
- Automatic Driver Management
- HTML Reporting
- Screenshot Capture
- Logging
- CI/CD Pipeline
- Scalable Framework Design
- Allure Reports
- Parallel Execution (pytest-xdist)
- Docker Support
- Jenkins Pipeline
- Browser Matrix Testing
- Slack Notifications
- Email Test Reports
Muhammad Hassnain Raza
Software Quality Assurance Engineer
GitHub: https://github.com/hassnain11
If you found this project useful, consider giving it a ⭐ on GitHub.
It helps support the project and motivates further improvements.