Skip to content

saisyah101/Selenium-Cucumber-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Selenium Cucumber Java - E-Commerce Website Test Automation

A BDD (Behavior-Driven Development) test automation framework for Practice Software Testing ToolShop e-commerce website testing using Selenium WebDriver, Cucumber, and Java with TestNG integration.

Table of Contents

Overview

This framework demonstrates test automation practices for testing ToolShop e-commerce website. Built with BDD methodology, it provides comprehensive test coverage for authentication, product management, checkout processes, and end-to-end user journeys.

Features

  • BDD Framework: cucumber with Gherkin syntax for readable test scenarios
  • Page Object Model: modular and maintainable page object architecture
  • Multi-Browser Support: chrome and Firefox with configurable options
  • Headless Mode: configurable headless execution for CI/CD
  • Parallel Execution: TestNG parallel test execution support
  • Dynamic Test Data: random data generation for unique test scenarios
  • Video Recording: optional screen recording with WebM conversion
  • Comprehensive Assertions: detailed validation methods
  • Project Structure

    automation-framework/
    ├── src/
    │   ├── main/
    │   │   └── java/
    │   │       ├── driver/
    │   │       │   └── DriverFactory.java           # WebDriver management
    │   │       ├── pageObjects/
    │   │       │   ├── Base_PO.java                 # Base page object with utilities
    │   │       │   ├── Auth_PO.java                 # Authentication pages
    │   │       │   ├── Product_PO.java              # Product listing & filtering
    │   │       │   └── EndToEnd_PO.java             # Checkout & transaction flow
    │   │       ├── properties/
    │   │       │   └── config.properties            # Configuration file
    │   │       └── utils/
    │   │           └── Global_Vars.java             # Global constants & test data
    │   └── test/
    │       ├── java/
    │       │   ├── runners/
    │       │   │   ├── MainRunner.java              # Main Runner
    │       │   │   └── testng/
    │       │   │       └── testng.xml               # TestNG configuration
    │       │   └── stepDefinitions/
    │       │       ├── base/
    │       │       │   └── Hooks.java               # Before/After hooks
    │       │       ├── Auth_Steps.java              # Authentication step definitions
    │       │       ├── ProductPage_Steps.java       # Product page step definitions
    │       │       └── EndToEnd_Steps.java          # E2E transaction step definitions
    │       └── resources/
    │           └── features/
    │               ├── Auth.feature                 # Authentication scenarios
    │               ├── ProductPage.feature          # Product page scenarios
    │               ├── Checkout.feature             # Checkout scenarios
    │               └── EndToEnd.feature             # E2E transaction scenarios
    ├── pom.xml                                      # Maven dependencies
    ├── .gitignore
    └── README.md
    

    Prerequisites

  • Java JDK 21 or higher
  • Maven 3.6+
  • Chrome Browser (for Chrome tests)
  • Firefox Browser (for Firefox tests)
  • FFmpeg (optional, for video recording conversion)
  • Installation

    1. Clone the repository

    git clone https://github.com/saisyah101/Selenium-Cucumber-Java.git
    cd Selenium-Cucumber-Java/automation-framework

    2. Install dependencies

    mvn clean install

    3. Configure properties

    Create or edit src/main/java/properties/config.properties:
    browser=chrome
    headless=false

    Configuration

    Browser Configuration

    Edit config.properties or use system properties:

    # Run with Chrome
    mvn test -DbrowserType=chrome
    # Run with Firefox mvn test -DbrowserType=firefox
    # Run in headless mode mvn test -Dheadless=true

    Parallel Execution

    Configure in testng.xml:

    <suite name="Suite1" parallel="classes" data-provider-thread-count="3">
    

    Video Recording

    Enable/disable in Hooks.java:

    private static final boolean ENABLE_VIDEO_RECORDING = false;

    Running Tests

    Run all tests

    mvn clean test

    Run specific feature

    mvn test -Dcucumber.filter.tags="@auth"

    Run with specific tags

    # Authentication tests
    mvn test -Dcucumber.filter.tags="@auth"
    # Product page tests mvn test -Dcucumber.filter.tags="@productpage"
    # End-to-end tests mvn test -Dcucumber.filter.tags="@E2E"
    # Guest user tests mvn test -Dcucumber.filter.tags="@guest"
    # Authenticated user tests mvn test -Dcucumber.filter.tags="@authenticated"
    # Specific scenario mvn test -Dcucumber.filter.tags="@user-transaction"

    Run in specific browser

    # Chrome
    mvn test -DbrowserType=chrome
    # Firefox mvn test -DbrowserType=firefox
    # Headless Chrome mvn test -DbrowserType=chrome -Dheadless=true

    Test Scenarios

    Authentication Tests (Auth.feature)

    Positive Scenarios

  • Register new account and login
  • Login with existing credentials
  • Logout functionality
  • Negative Scenarios

  • Empty email field
  • Empty password field
  • Invalid email format
  • Invalid password length
  • Incorrect credentials
  • Product Page Tests (ProductPage.feature)

    Guest User Tests

  • Search products by keyword
  • Search and reset filters
  • Filter by price range with slider
  • Sort by name (A-Z, Z-A)
  • Sort by price (High-Low, Low-High)
  • Filter by category (Hand Saw, Power Tools, Chisels)
  • Filter by brand
  • Filter eco-friendly products
  • Attempt to add favorites (should fail)
  • Authenticated User Tests

  • Search products by keyword
  • Search and reset filters
  • Filter by price range with slider
  • Sort by name (A-Z, Z-A)
  • Sort by price (High-Low, Low-High)
  • Filter by category (Hand Saw, Power Tools, Chisels)
  • Filter by brand
  • Filter eco-friendly products
  • Add product to favorites
  • Remove product from favorites
  • End-to-End Transaction Tests (EndToEnd.feature)

    Complete checkout flow with multiple payment methods:

  • Bank Transfer
  • Cash on Delivery
  • Credit Card
  • Buy Now Pay Later
  • Gift Card
  • Transaction Flow:

  • Add product to cart
  • Review cart details
  • Login verification
  • Billing address confirmation
  • Payment selection and data entry
  • Order confirmation
  • Invoice generation
  • Invoice verification
  • Author

    Siti Aisyah
    LinkedIn

    About

    No description, website, or topics provided.

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published