A comprehensive automated testing framework for e-commerce applications using Python, Selenium, and Pytest. This project demonstrates QA Automation skills and Python-Selenium expertise.
This test suite implements the Page Object Model (POM) pattern to test various e-commerce functionalities including:
- User authentication (Login)
- Product search
- Shopping cart operations
- Checkout process
- Python 3.8+ - Programming language
- Selenium 4.15.2 - Web automation framework
- Pytest 7.4.3 - Test framework and runner
- Pytest-HTML - HTML test reports
- Pytest-Xdist - Parallel test execution
- WebDriver Manager - Automatic driver management
- Python-dotenv - Environment variable management
- Allure Pytest - Advanced test reporting
ecommerce-test-suite/
βββ tests/ # Test cases
β βββ test_login.py # Login functionality tests
β βββ test_search.py # Search functionality tests
β βββ test_cart.py # Shopping cart tests
β βββ test_checkout.py # Checkout process tests
βββ pages/ # Page Object Model classes
β βββ login_page.py # Login page interactions
β βββ search_page.py # Search page interactions
β βββ cart_page.py # Cart page interactions
β βββ checkout_page.py # Checkout page interactions
βββ utils/ # Utility functions
β βββ driver_setup.py # WebDriver initialization
β βββ config.py # Configuration and test data
βββ demo-site/ # Demo e-commerce website (for testing)
β βββ index.html # Homepage
β βββ login.html # Login page
β βββ products.html # Product listing
β βββ cart.html # Shopping cart
β βββ checkout.html # Checkout page
β βββ ... # Other pages and assets
βββ conftest.py # Pytest fixtures and configuration
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore rules
βββ README.md # Project documentation
- Python 3.8 or higher
- pip (Python package manager)
- A web browser (Chrome, Firefox, or Edge)
- Git (optional, for version control)
-
Clone or download the project
git clone <repository-url> cd ecommerce-test-suite
-
Create a virtual environment (recommended)
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Start the demo e-commerce site
# Navigate to demo-site folder cd demo-site # Start local server (choose one): # Option 1: Python HTTP Server python -m http.server 8000 # Option 2: Use provided script # Windows: start-server.bat # Linux/Mac: chmod +x start-server.sh ./start-server.sh
The demo site will be available at:
http://localhost:8000 -
Configure environment variables (optional)
# Copy the example file cp .env.example .env # Edit .env file if you want to change default settings # Default settings work with the demo site
The included demo site uses these credentials:
- Email:
[email protected] - Password:
test123
Edit the .env file to configure:
- BASE_URL: The e-commerce site URL to test (default:
http://localhost:8000) - TEST_USERNAME: Test account email (default:
[email protected]) - TEST_PASSWORD: Test account password (default:
test123) - BROWSER: Browser to use (chrome, firefox, edge)
- HEADLESS: Run tests in headless mode (True/False)
- IMPLICIT_WAIT: Implicit wait time in seconds
- EXPLICIT_WAIT: Explicit wait time in seconds
pytestpytest tests/test_login.pypytest tests/test_login.py::TestLoginpytest tests/test_login.py::TestLogin::test_valid_login# Run only smoke tests
pytest -m smoke
# Run only regression tests
pytest -m regression
# Run login-related tests
pytest -m loginpytest -n autopytest --html=report.html --self-contained-html# Run tests with Allure
pytest --alluredir=allure-results
# Generate and open report
allure serve allure-results- β Valid login with correct credentials
- β Invalid email login attempt
- β Invalid password login attempt
- β Empty credentials validation
- β Special characters handling
- β Search valid product
- β Search invalid/non-existent product
- β Search with special characters
- β Empty search handling
- β Case-insensitive search
- β Search and select product
- β Add product to cart
- β Remove product from cart
- β Update cart quantity
- β Empty cart verification
- β Cart total calculation
- β Complete checkout with valid details
- β Checkout without accepting terms
- β Checkout with empty cart
- β Billing details validation
This project follows the Page Object Model pattern:
- Pages: Each page has its own class with locators and methods
- Tests: Test files contain test cases that use page objects
- Utils: Common utilities like driver setup and configuration
from pages.login_page import LoginPage
# Initialize page object
login_page = LoginPage(driver)
# Use page methods
login_page.navigate_to_login()
login_page.login("[email protected]", "password123")
assert login_page.is_login_successful()After running tests, open report.html in a browser to view detailed test results.
For more advanced reporting with Allure:
- Run tests:
pytest --alluredir=allure-results - Generate report:
allure serve allure-results
Failed tests automatically capture screenshots in the screenshots/ directory.
- Ensure you have the latest browser version installed
- WebDriver Manager will automatically download the correct driver
- If issues persist, manually download drivers from browser vendors
- Ensure virtual environment is activated
- Verify all dependencies are installed:
pip install -r requirements.txt - Check that you're running tests from the project root directory
- Update locators in page objects if the website structure changes
- Use browser DevTools to inspect elements and find correct selectors
This project is designed as a learning resource. Key concepts demonstrated:
- Page Object Model: Separation of page logic from test logic
- Explicit Waits: Handling dynamic content loading
- Test Fixtures: Reusable test setup and teardown
- Test Markers: Organizing and filtering tests
- Configuration Management: Environment-based settings
- Error Handling: Robust test execution
This is a learning project. Feel free to:
- Add more test cases
- Improve existing tests
- Enhance page objects
- Add new features
This project is for educational purposes.
Egemen GΓΌney KOΓ
- Software Developer & QA Automation Engineer
- Portfolio: egemenguney.net
- GitHub: @egemenguney
- Portfolio Website: egemenguney.net
- Project Repository: GitHub
- CI/CD Status:
- Selenium WebDriver community
- Pytest framework maintainers
This project includes a complete demo e-commerce site (demo-site/) for testing purposes. The demo site includes:
- β Login/authentication system
- β Product search functionality
- β Shopping cart with add/remove/update
- β Complete checkout process
- β Order confirmation
All locators in the test suite are designed to work with the included demo site. The demo site uses localStorage for data persistence, so no backend server is required.
# Build and run tests
docker-compose up --build
# Run tests only
docker-compose run test-suite pytest tests/ -v
# Run specific test
docker-compose run test-suite pytest tests/test_login.py -v# Build image
docker build -t ecommerce-test-suite .
# Run container
docker run --rm ecommerce-test-suiteThis project includes GitHub Actions CI/CD pipeline that:
- β Runs tests on multiple Python versions (3.8-3.12)
- β Tests on multiple browsers (Chrome, Firefox)
- β Generates test reports and coverage
- β Runs code quality checks (Black, Flake8, Pylint)
- β Uploads test artifacts
The pipeline runs automatically on:
- Push to
mainordevelopbranches - Pull requests to
mainordevelopbranches
View the workflow file: .github/workflows/ci.yml
Generate coverage report:
# Install coverage tool
pip install pytest-cov
# Run tests with coverage
pytest --cov=pages --cov=utils --cov-report=html --cov-report=term
# View HTML report
open htmlcov/index.htmlInstall and use pre-commit hooks for code quality:
# Install pre-commit
pip install pre-commit
# Install hooks
pre-commit install
# Run hooks manually
pre-commit run --all-files# Format code with Black
black .
# Check formatting
black --check .# Run Flake8
flake8 .
# Run Pylint
pylint pages/ utils/ tests/The project includes centralized logging. Logs are saved to logs/ directory with timestamps.
from utils.logger import get_logger
logger = get_logger()
logger.info("Test started")
logger.error("Test failed")This project demonstrates:
- β Page Object Model (POM) - Separation of concerns
- β Explicit Waits - Robust element location
- β Configuration Management - Environment-based settings
- β Test Fixtures - Reusable setup/teardown
- β Test Markers - Test organization and filtering
- β Screenshot on Failure - Debugging support
- β Multiple Browser Support - Cross-browser testing
- β Parallel Execution - Faster test runs
- β CI/CD Integration - Automated testing
- β Docker Support - Containerized testing
- β Code Quality Tools - Maintainable codebase
- β Comprehensive Logging - Better debugging
Note: This test suite is designed to work with the included demo site. To test other e-commerce sites, update locators in the page objects according to your target application.