Cucumber - DataTables
So far we have been passing one arguement in every step of our scenario.
There could be times when we need to pass more than one arguements from a step. This is were datatables are very handy.
Let's try a different way of writing the same scenario that we have using a datable example.
Consider the following scenario.
Scenario: Sign-up a new user with datatable example Given the user is on landing page When she chooses to sign up And she provides the her details as follows: | firstName | lastName | email | password | | Sukesh | Kumar | [email protected] | password | And she signs-up Then she should be logged in to the application
So this scenario would result in the same behavior like the other two we have written so far. The only difference here is the way we are passing the data values.
Notice that the first 2 lines were moved to Background in the earlier chapter. You will have to remove the same from this scenario when your try to run it, otherwise cucumber will try to execute it twice and that may throw some unwanted behavior.
Also, understand that this is not a data driven scenario. It willl run only once and the datatable's scope is limited to the step where it is passed.