Answer
Parameterization Symbols in Cucumber
Two Types of Parameterization
1. Scenario Outline — Angle Brackets < >
Placeholders in step text use <angle brackets>:
Gherkin
Scenario Outline: Login with <role>
When the user enters "<username>" and "<password>"
Then the user sees the "<dashboard>"
Examples:
| role | username | password | dashboard |
| admin | admin | Admin@123 | AdminHome |
| manager | manager | Mgr@456 | MgrHome |
2. Examples / Data Tables — Pipe Symbol |
The pipe symbol | is used to define tabular data:
Gherkin
Examples:
| filename |
| file1 |
| file2 |
Or for inline Data Tables:
Gherkin
When the user submits the registration form:
| Field | Value |
| FirstName | John |
| LastName | Doe |
| Email | john@example.com |
| Mobile | 9876543210 |
In Step Definitions
Java
// Scenario Outline parameters passed as method arguments
@When("the user enters {string} and {string}")
public void enterCredentials(String username, String password) {
// username, password come from Examples table row
}
// Data Table accessed via DataTable object
@When("the user submits the registration form:")
public void submitForm(DataTable dataTable) {
Map<String, String> formData = dataTable.asMap(String.class, String.class);
String firstName = formData.get("FirstName");
String email = formData.get("Email");
}
Cucumber Expressions for Parameters
Java
{string} // matches "quoted string"
{int} // matches integer: 42
{float} // matches decimal: 3.14
{word} // matches single word (no spaces)
{} // matches anything (anonymous)
