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

https://github.com/sandipchopkar95/java_selenium_junit-bdd_demoblaze

This is a Behavior Driven Development (BDD) test automation framework using Selenium WebDriver, Java, JUnit, and Cucumber. It follows Page Object Model (POM) design principles and is structured for scalable and maintainable test automation.
https://github.com/sandipchopkar95/java_selenium_junit-bdd_demoblaze

bdd cucumber cucumber-java java selenium

Last synced: 28 days ago
JSON representation

This is a Behavior Driven Development (BDD) test automation framework using Selenium WebDriver, Java, JUnit, and Cucumber. It follows Page Object Model (POM) design principles and is structured for scalable and maintainable test automation.

Awesome Lists containing this project

README

          

# Java Selenium BDD Framework with JUnit

This is a Behavior Driven Development (BDD) test automation framework using **Selenium WebDriver**, **Java**, **JUnit**, and **Cucumber**. It follows **Page Object Model (POM)** design principles and is structured for scalable and maintainable test automation.

---

## ๐Ÿ“ Project Structure

```
src/
โ”œโ”€โ”€ main/
โ”‚ โ””โ”€โ”€ java/com/personal/demoblaze/
โ”‚ โ”œโ”€โ”€ AppConstants/ # Application constants
โ”‚ โ”‚ โ””โ”€โ”€ AppConstant.java
โ”‚ โ”œโ”€โ”€ config/ # Driver and config setup
โ”‚ โ”‚ โ”œโ”€โ”€ ConfigReader.java
โ”‚ โ”‚ โ””โ”€โ”€ DriverManager.java
โ”‚ โ”œโ”€โ”€ pages/ # Page Object Model classes
โ”‚ โ”‚ โ”œโ”€โ”€ CartPage.java
โ”‚ โ”‚ โ”œโ”€โ”€ ContactUs.java
โ”‚ โ”‚ โ”œโ”€โ”€ HomePage.java
โ”‚ โ”‚ โ”œโ”€โ”€ LoginPage.java
โ”‚ โ”‚ โ””โ”€โ”€ MyAccountPage.java
โ”‚ โ””โ”€โ”€ utils/ # Utility classes
โ”‚ โ”œโ”€โ”€ ScreenshotUtil.java
โ”‚ โ””โ”€โ”€ WaitHelper.java
โ”‚
โ”œโ”€โ”€ test/
โ”‚ โ””โ”€โ”€ java/com/personal/demoblaze/
โ”‚ โ”œโ”€โ”€ basetest/ # Base test class
โ”‚ โ”‚ โ””โ”€โ”€ BaseTest.java
โ”‚ โ”œโ”€โ”€ runners/ # Cucumber test runners
โ”‚ โ”‚ โ””โ”€โ”€ TestRunner.java
โ”‚ โ””โ”€โ”€ stepdefinitions/ # Step definition classes
โ”‚ โ”œโ”€โ”€ HomePage_Steps.java
โ”‚ โ”œโ”€โ”€ Login_Logout_Steps.java
โ”‚ โ””โ”€โ”€ MyAccountPage_Steps.java
โ”‚
โ”œโ”€โ”€ resources/
โ”‚ โ”œโ”€โ”€ config.properties # Test configuration
โ”‚ โ””โ”€โ”€ features/homepage/ # Feature files
โ”‚ โ”œโ”€โ”€ HomePage.feature
โ”‚ โ”œโ”€โ”€ Login_LogOut.feature
โ”‚ โ”œโ”€โ”€ MyAccountPage.feature
โ”‚ โ””โ”€โ”€ cucumber.properties
```

---

## ๐Ÿš€ Getting Started

### Prerequisites

- Java JDK 11+
- Maven 3.6+
- IDE (IntelliJ IDEA, Eclipse, etc.)
- Browser driver (e.g., ChromeDriver)

### Installation

Clone the repository and navigate to the project root directory.

```bash
git clone https://github.com/your-repo/demoblaze-bdd-framework.git
cd demoblaze-bdd-framework
```

Install dependencies:

```bash
mvn clean install
```

---

## ๐Ÿงช Running Tests

Run the test suite using Maven:

```bash
mvn test
```

Or directly run via JUnit in your IDE using `TestRunner.java`.

---

## ๐Ÿงพ Writing Feature Files

Feature files are written in **Gherkin** syntax and located in `src/test/resources/features/homepage/`.

Example:

```gherkin
Feature: Login Functionality

Scenario: Successful login with valid credentials
Given user is on login page
When user enters valid username and password
Then user should be redirected to the homepage
```

---

## ๐Ÿงฉ Step Definitions

Step definitions are implemented in `stepdefinitions/` and mapped to feature file steps using Cucumber annotations:

```java
@Given("user is on login page")
public void user_is_on_login_page() {
loginPage.navigateToLogin();
}
```

---

## โš™ Configuration

Edit `config.properties` to change environment settings such as:

```properties
browser=chrome
baseUrl=https://demoblaze.com
implicitWait=10
```

---

## ๐Ÿ“ธ Utilities

- `ScreenshotUtil.java`: Captures screenshots on failures.
- `WaitHelper.java`: Provides custom wait logic.

---

## ๐Ÿงฑ Base Test

`BaseTest.java` handles browser setup and teardown using JUnit `@Before` and `@After`.

---

## ๐Ÿ“‚ Reporting

Integrate tools like **ExtentReports**, **Allure**, or **Cucumber Reports** for advanced reporting (not included in base setup).

---