Data Tables (Scenario Outlines)

Data Tables are a standard practice to pass data in a tabular format. Tabular formats have an advantage in that it can represent large data sets in a comprehensible manner and there are many viewers and editors that can read tabular format. Of course when we come to programming, a table can be something in memory as a data structure and the how we might create the data structure and how we represent that data structure to different sets of audience is a nice topic to discuss in itself. Suffice to say here that we can represent a tabular data structure in multiple file formats like excel, csv, tab separated, xml, json, yml and pretty much any customized format.

Use Case:

We fill forms on websites and hit submit and this is one of the most common functionality that we come across. While Automation, we might have to test the form with multiple sets of data. For example the below web form has lots of fields in it and our requirement might be to test the data with different data sets.


Scenario Outline:

Behave gives us a construct called Scenario Outline to be able to parameterize the data table and also loop through each data set repeating the operations on the form submission. The other keyword to be used is Examples: Behave picks the data parameter values from the Examples: and loops through the data table.

In the below behave example, the form gets filled with each row in the data table and the operations are repeated for each row. Didn’t that reduce our work of specifying the operations for each data set in a separate scenario?

Entire Cucumber Scenario:

For some reason, The “< characters are not rendered correctly in the below cucumber scenario gherkin code (So if you copy, please ensure that you replace the garbled characters. I am posting a picture to help. Otherwise download the file from here




While typing the table with pipe symbols, you may find it is not formatted correctly. In RubyMine (while your cursor is anywhere in the feature file), on your keyboard “Ctrl+Alt+L” will format the gherkin including the table very nicely for you


Step Definitions: