Skip to content

Buffden/Automated-Testing-with-Selenium

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automated Testing with Selenium - DemoBlaze Assignment

This repository contains the complete automated testing solution for the DemoBlaze e-commerce website as part of the Graduate Assignment: Automated Testing with Selenium.

Project Overview

This project implements comprehensive automated test cases for the DemoBlaze website using Selenium WebDriver, Python, and the Page Object Model design pattern. The solution covers login functionality, shopping cart operations, product details verification, checkout process, and UI element validation.

Project Structure

.
├── selenium/              # Selenium project source code
│   ├── pages/            # Page Object Model classes
│   │   ├── base_page.py
│   │   ├── home_page.py
│   │   ├── login_page.py
│   │   ├── product_page.py
│   │   ├── cart_page.py
│   │   └── checkout_page.py
│   ├── tests/             # Test cases
│   │   ├── test_login.py
│   │   ├── test_cart.py
│   │   ├── test_product_details.py
│   │   ├── test_checkout.py
│   │   └── test_ui_elements.py
│   ├── utils/             # Utilities and helpers
│   │   ├── config.py
│   │   ├── driver_factory.py
│   │   └── helpers.py
│   ├── pytest.ini         # Pytest configuration
│   └── run_tests.py       # Test runner script
├── docs/                  # Documentation
│   ├── README.md          # Detailed project documentation
│   └── TEST_CASES.md      # Test case documentation
├── reports/               # Test execution reports
│   ├── screenshots/       # Screenshots of test failures
│   ├── logs/              # Test execution logs
│   └── test_report.html   # HTML test report
├── venv/                  # Python virtual environment
├── requirements.txt       # Python dependencies
└── Assignment 2.pdf       # Assignment PDF

Quick Start

Prerequisites

  • Python 3.x
  • Chrome and Firefox browsers installed
  • Internet connection (for downloading browser drivers)

Setup

  1. Clone or navigate to the project directory:

    cd "Selenium Project"
  2. Activate virtual environment:

    source venv/bin/activate
  3. Install dependencies (if not already installed):

    pip install -r requirements.txt
  4. Run tests:

    cd selenium
    pytest --browser chrome

Test Execution

Run All Tests

Important: Always run pytest from the selenium/ directory to ensure configuration files are found.

cd selenium
pytest --browser chrome

Run Tests on Different Browsers

Chrome (headed):

cd selenium
pytest --browser chrome

Firefox (headed):

cd selenium
pytest --browser firefox

Chrome (headless):

cd selenium
pytest --browser chrome --headless

Firefox (headless):

cd selenium
pytest --browser firefox --headless

Run All Browsers and Modes

cd selenium
python run_tests.py

Test Cases Implemented

  1. Login Functionality (2 test cases)

    • Valid credentials login
    • Invalid credentials login
  2. Shopping Cart (3 test cases)

    • Add product to cart
    • Remove product from cart
    • Cart empty state
  3. Product Details (1 test case)

    • Verify product name, price, and description
  4. Checkout Process (1 test case)

    • Complete checkout with form submission
  5. UI Elements (2 test cases)

    • Homepage UI elements
    • Product page UI elements

Total: 9 test cases covering all required functionalities.

Design Patterns

This project follows the Page Object Model (POM) design pattern:

  • Separation of Concerns: Page objects separate UI elements from test logic
  • Maintainability: Easy to update when UI changes
  • Reusability: Page objects can be reused across multiple tests
  • Readability: Tests are clean and readable

Features

  • ✅ Page Object Model implementation
  • ✅ Explicit waits for dynamic elements
  • ✅ Screenshot capture on failures
  • ✅ Multi-browser support (Chrome, Firefox)
  • ✅ Headless and headed mode support
  • ✅ HTML test reports
  • ✅ Comprehensive logging
  • ✅ Modular and maintainable code structure

Reports and Artifacts

After test execution, reports are generated in the reports/ directory:

  • HTML Report: reports/test_report.html
  • Screenshots: reports/screenshots/ (captured during test execution)
  • Logs: reports/logs/ (detailed execution logs)

Documentation

  • Detailed Documentation: See docs/README.md
  • Test Cases: See docs/TEST_CASES.md
  • Assignment PDF: Assignment 2.pdf

Configuration

Test configuration is managed in selenium/utils/config.py:

  • Base URL: https://www.demoblaze.com
  • Timeouts: Configurable implicit and explicit waits
  • Browser options: Chrome and Firefox specific configurations

Notes

  • DemoBlaze is a demo application. Some features may require account creation.
  • Browser drivers are automatically managed by webdriver-manager.
  • Screenshots are automatically captured on test failures and key test steps.

Assignment Requirements Met

Test Scenario Identification (20%): 9+ test cases documented
Test Script Creation (40%): Complete POM implementation with Selenium
Test Execution (20%): Chrome and Firefox in headless/headed modes
Reporting (20%): HTML reports, screenshots, and logs

References

License

This project is created for educational purposes as part of a graduate assignment.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors