Feature files
Write scenarios in plain English using Gherkin. Each scenario describes a behavior from the user's perspective.
Feature: OrangeHRM Login validation Background: Given user is on orangeHRM login page Scenario: Successful login When user enters username "Admin" and password "admin123" And clicks on login button Then user should be logged in successfully
Step definitions
Map each Gherkin step to Java methods using Cucumber annotations.
@Given("user is on orangeHRM login page")
public void openLoginPage() {
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
driver.manage().window().maximize();
driver.get("http://localhost:8080/orangehrm");
}
@When("user enters username {string} and password {string}")
public void enterCredentials(String username, String password) {
driver.findElement(By.name("username")).sendKeys(username);
driver.findElement(By.name("password")).sendKeys(password);
}
Scenario outline
Use examples tables to run the same scenario with multiple inputs.
Scenario Outline: Multiple login attempts When user enters username "" and password " " And clicks on login button Then user should see " " Examples: | username | password | result | | Admin | admin123 | success| | Admin | wrong123 | error |
Local BDD notes
The Cucumber examples on this page are based on your local BDD notes in BDD.txt. This keeps the training material accessible directly from the site.
Feature file structure
Background, scenarios, and scenario outlines are defined in Gherkin for readable test behavior.
Step definitions
Java methods map Gherkin steps to Selenium WebDriver actions for browser automation.
Local runner guidance
Use your local Cucumber runner setup instead of external docs when configuring `@CucumberOptions`.