This is an end-to-end test automation project for an e-commerce website using Selenium WebDriver and Pytest. The project implements the Page Object Model (POM) design pattern to create maintainable and scalable test automation code.
- Python 3.12 - Programming language
- Selenium WebDriver - Browser automation
- Pytest - Testing framework
- WebDriver Manager - Automatic driver management
- Page Object Model (POM) - Design pattern for maintainable code
- Application navigation
- Store password authentication
- Featured products listing
- Search icon interaction
- Product search with predictive results
- Products section validation
- Product selection from search results
- Product page verification
- Product variant selection (Sunset variant)
- Add to cart functionality
- Cart drawer verification
- Checkout button interaction
- Product presence validation in cart
- Payment page validation
- Navigation back to store
- Order summary verification
AdNabu_Assignment/
β
βββ pages/ # Page Object Model classes
β βββ __init__.py
β βββ home_page.py # Home page interactions
β βββ search_page.py # Search functionality
β βββ product_page.py # Product details and cart
β βββ cart_page.py # Cart management
β βββ checkout_page.py # Checkout process
β
βββ tests/ # Test files
β βββ __init__.py
β βββ test_complete_purchase_flow.py # End-to-end test
β
βββ utils/ # Utility modules
β βββ __init__.py
β βββ driver_setup.py # WebDriver configuration
β
βββ conftest.py # Pytest fixtures and configuration
βββ pytest.ini # Pytest configuration
βββ requirements.txt # Python dependencies
βββ .gitignore # Git ignore rules
βββ README.md # Project documentation
- Python 3.12 or higher
- Git for version control
- Google Chrome browser (latest version recommended)
- Internet connection for downloading WebDriver
git clone https://github.com/md-Arif-QA/adnabu-qa-assignment.git
cd adnabu-qa-assignmentEnsure you have Python 3.12 installed:
python --version
# Should show: Python 3.12.xIf you don't have Python 3.12, download it from python.org.
Create a virtual environment to isolate project dependencies:
# Create virtual environment named 'venv'
python -m venv venvActivate the virtual environment:
Windows (PowerShell/Command Prompt):
# PowerShell
venv\Scripts\Activate.ps1
# Command Prompt
venv\Scripts\activate.batmacOS/Linux:
source venv/bin/activateAfter activation, your terminal prompt should show (venv) at the beginning.
Install all required Python packages:
pip install -r requirements.txtThis will install:
selenium- Web browser automationpytest- Testing frameworkwebdriver-manager- Automatic ChromeDriver management
Verify that all packages are installed correctly:
pip listYou should see packages like:
- selenium
- pytest
- webdriver-manager
pytestpytest -vpytest -v -spytest --html=reports/test_report.html --self-contained-htmlThis generates a detailed HTML report in the reports/ directory.
pytest --junitxml=reports/test_results.xmlpytest tests/test_complete_purchase_flow.py::TestCompletePurchaseFlow::test_search_add_cart_checkout_flow --html=reports/test_report.html --self-contained-html -v -sThe main test test_search_add_cart_checkout_flow performs a complete e-commerce purchase flow:
- Setup: Initialize WebDriver and page objects
- Home Page: Open application and enter store password
- Product Discovery: List all featured products
- Search: Search for "The Complete Snowboard"
- Product Selection: Select product from search results
- Product Details: Verify product page and select variant
- Add to Cart: Add product to shopping cart
- Cart Verification: Verify cart contents
- Checkout: Proceed to checkout and verify payment page
- Navigation: Return to store and verify cart persistence
- Teardown: Close browser automatically
Test execution provides detailed console output with:
- Step-by-step progress indicators
- Product listing information
- Verification confirmations
- Error details (if any)
The project supports generating comprehensive test reports:
- Generated using
pytest-htmlplugin - Self-contained HTML files with detailed test results
- Includes screenshots, logs, and execution times
- Located in
reports/test_report.html
- Standard XML format for CI/CD integration
- Contains test results, durations, and failure details
- Located in
reports/test_results.xml
- Run tests with report generation:
pytest --html=reports/test_report.html --self-contained-html - Open the generated HTML file in any web browser
- Review test execution details, timings, and any failures
Note: A sample test report (reports/test_report.html) is included in the repository for reference.
-
ChromeDriver Issues
- Ensure Google Chrome is installed and updated
- WebDriver Manager handles driver downloads automatically
-
Virtual Environment Issues
- Ensure virtual environment is activated (check
(venv)in prompt) - Try deactivating and reactivating:
deactivatethen activate again
- Ensure virtual environment is activated (check
-
Import Errors
- Verify all dependencies are installed:
pip install -r requirements.txt - Check Python version compatibility
- Verify all dependencies are installed:
-
Test Failures
- Check internet connection for website access
- Verify website is accessible and not under maintenance
- Check console output for specific error messages
If you encounter issues:
- Check the console output for error messages
- Verify all prerequisites are met
- Ensure virtual environment is properly activated
- Check that all dependencies are installed
- Tests are designed to run in a real browser environment
- Chrome browser window will open and close automatically during test execution
- Test execution may take 1-2 minutes depending on network conditions
- All test data and URLs are configured for the AdNabu test environment
- Fork the repository: https://github.com/md-Arif-QA/adnabu-qa-assignment
- Create a feature branch (
git checkout -b feature/your-feature) - Make your changes and add comments where needed
- Run tests to ensure everything works:
pytest -v -s - Commit your changes (
git commit -m 'Add your feature') - Push to your fork (
git push origin feature/your-feature) - Submit a pull request with detailed description
For questions or issues, please open an issue on GitHub Issues.
Happy Testing! π