Skip to content

BDD testing framework for a Todo app using Cucumber and Selenium WebDriver. Supports Chrome, Firefox, and Edge with a clean Page Object Model. Integrates TestNG for parallel test runs, uses simple config files for different environments, and automates user login and task creation.

Notifications You must be signed in to change notification settings

OmarElsheikh1/cucumber-todo-testing-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🥒 Cucumber Todo Testing Framework

Java Selenium Cucumber TestNG

A robust UI automation framework for the QACart Todo App using Java, Selenium WebDriver, Cucumber, and TestNG. Follows the Page Object Model (POM), supports multi-browser execution, and is optimized for maintainability and CI/CD pipelines.


✨ Key Features

  • BDD Approach: Gherkin scenarios for business-readable tests
  • 🌐 Cross-Browser: Chrome/Firefox/Edge support
  • ⚙️ Environment Configs: Local/Staging/Production setups
  • 🧵 Thread-Safe: Parallel execution ready
  • 📊 CI/CD: GitHub Actions integration
  • 📄 Logging: Detailed execution logs

🧩 Project Structure

📁 src/test
├── 📁 java
│   └── 📁 com.qacart.todo
│       ├── 📁 base        # Core WebDriver setup
│       ├── 📁 factory     # Browser instantiation
│       ├── 📁 hooks       # Test lifecycle management
│       ├── 📁 pages       # POM classes (LoginPage, TodoPage)
│       ├── 📁 runners     # TestNG cucumber runners
│       ├── 📁 steps       # Gherkin step implementations
│       └── 📁 utils       # Config helpers
└── 📁 resources
    ├── 📁 features       # Business scenarios
    └── 📁 properties     # Environment configs

⚡ Quick Start

✅ Prerequisites

  • Java 21+
  • Maven 3.8+

▶️ Run Tests

# Default: Chrome + STAGING
mvn clean test

# Custom environment and browser
mvn test -Dbrowser=firefox -Denv=PRODUCTION

🔧 Configuration

1. Environment Setup

Edit properties in:

src/test/resources/properties/
├── local.properties
├── staging.properties
└── production.properties

2. Browser Management

Supported browsers via -Dbrowser flag:

chrome | firefox | edge 

🧪 Sample Test

Feature File (user.feature):

Feature: User Features

  Scenario: User should be able to login
    Given User is at the login page
    When User fill the email and password and login
    Then Welcome message should be displayed

Step Definition:

@Given("User is at the login page")
    public void userIsAtTheLoginPage() throws IOException {

        // Initialize the WebDriver using the DriverFactory
        driver = DriverFactory.getDriver();

        // Navigate to the login page of the application
        new LoginPage(driver).load(EnvUtils.getInstance().getUrl() + "/login");
    }
@When("User fill the email and password and login")
    public void userFillTheEmailAndPassword() throws IOException {

        // Log in to the application by using the LoginPage class
        new LoginPage(driver).login(EnvUtils.getInstance().getEmail(), EnvUtils.getInstance().getPassword());
    }

@Then("Welcome message should be displayed")
    public void welcomeMessageShouldBeDisplayed() {

        // Verify that the welcome message is displayed after login
        boolean isWelcomeDisplayed = new TodoPage(driver).isWelcomeMessageDisplayed();
        Assert.assertTrue(isWelcomeDisplayed, "Welcome message is not displayed");
    }

🚦 CI/CD Pipeline

Runs on push to master branch (.github/workflows/test.yml):

on:
  push:
    branches: ["main"]

jobs:
  test:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-java@v3
        with:
          java-version: '21'
      - uses: browser-actions/setup-chrome@latest
      - run: mvn clean test

📈 Reporting & Logging

  • HTML Reports: target/cucumber-reports/
  • Logs: logs/ via Log4j2
# Sample log output
[DEBUG] Initializing ChromeDriver...
[INFO] Loading PRODUCTION environment

💡 Best Practices

  1. Page Object Model (POM): Each page = single class
  2. Environment abstraction via EnvUtils
  3. Reusable steps: Modular, easy to maintain
  4. Parallel execution with ThreadLocal WebDriver

📜 License

Distributed under the MIT License. See the LICENSE file for more details.

About

BDD testing framework for a Todo app using Cucumber and Selenium WebDriver. Supports Chrome, Firefox, and Edge with a clean Page Object Model. Integrates TestNG for parallel test runs, uses simple config files for different environments, and automates user login and task creation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published