Transforming Data Tables to parse the test data
In the previous chapter, we covered how Data Tables can be used to send large sets of data to a single Step. Now let's understand how to handle Data Tables in Step Definitions in this recipe.
How to do it…
Let's assume we are writing Step Definitions for the following Scenario:
Scenario: Existing user Verification Given user is displayed login screen Then we verify following user exists | Name | Email | | Shankar | [email protected] | | Ram | [email protected] | | Sham | [email protected] |
Now run the Feature file, and copy paste the Cucumber Step Definitions suggestions in the
LoginSteps.java
class. These are the additional Steps inLoginSteps.java
:@Then("^we verify following user exists$") public void we_verify_following_user_exists(DataTable arg1) throws Throwable { /* Write code here that turns the phrase above into concrete actions For automatic transformation, change DataTable to...