Cucumber Sending Test Data in Steps using multiple arguments

Profile picture for user devraj

We sends different types of data using Steps. Steps sends data in form of string, integer or double which can be received in step definition in multiple ways. In your steps you pass data inside double quotes(" "). The text mentioned in between " " in steps is associated to capture groups in Step Definition files.

You can receive even more complex data using Data Table and Scenario outline in Cucumber.

How to pass multiple parameters in cucumber feature file

In a single step you can even pass more than one argument. Consider below Scenario here in first step (When I fill...) we are sending two arguments.

Scenario: Verify Login Functionality
  When I fill email with "goswami.tarun77@gmail.com" and password with "1234"  
  And I click on Sign in 

Check below how this data received in step definition

@When("I fill email with {string} and password with {string}")
public void i_fill_email_with_and_password_with(String string1, String string2) 
{
}

You can pass even int, double or any other value in Steps. Example: Check below step

When I enter price 1234.54

 Corresponding Step Definition will be

@When("I enter price {double}")
public void i_enter_price(Double double1) {

}

Similarly we can use int for integer.