An open API service indexing awesome lists of open source software.

https://github.com/omarelsheikh1/cucumber-todo-testing-framework

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.
https://github.com/omarelsheikh1/cucumber-todo-testing-framework

cucumber feature-test java maven selenium testng-framework

Last synced: about 1 month ago
JSON representation

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.

Awesome Lists containing this project

README

          

# ๐Ÿฅ’ Cucumber Todo Testing Framework

[![Java](https://img.shields.io/badge/Java-21-blue?logo=java)](https://docs.oracle.com/en/java/javase/21/)
[![Selenium](https://img.shields.io/badge/Selenium-4.0-green?logo=selenium)](https://www.selenium.dev/documentation/)
[![Cucumber](https://img.shields.io/badge/Cucumber-BDD-brightgreen?logo=cucumber)](https://cucumber.io/docs)
[![TestNG](https://img.shields.io/badge/TestNG-Testing-red)](https://testng.org/)

A robust UI automation framework for the [QACart Todo App](https://todo.qacart.com) 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

```bash
๐Ÿ“ 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
```bash
# Default: Chrome + STAGING
mvn clean test

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

---

## ๐Ÿ”ง Configuration

### 1. Environment Setup

Edit properties in:
```text
src/test/resources/properties/
โ”œโ”€โ”€ local.properties
โ”œโ”€โ”€ staging.properties
โ””โ”€โ”€ production.properties
```

### 2. Browser Management

Supported browsers via `-Dbrowser` flag:
```bash
chrome | firefox | edge
```

---

## ๐Ÿงช Sample Test
Feature File `(user.feature)`:

```gherkin
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:

``` java
@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`):

```yaml
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

``` properties
# 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.