Data Driven Framework with Excel


In this section, we will take an example and see how we put the data-driven concepts/capability to use. We will fill a contact us form on website with different data sets. The contact form looks as below with many input fields.



  1. You have completed the section “Set up Env” and have your environment ready with JDK, maven and Eclipse (+plugins)
  2. You have read and understood HTML DOM
  3. You were able to comprehend “Browser Commands” post
  4. You downloaded the project code base for data-driven-framework under – and imported into IntelliJ and the structure should look as below


If imported into eclipse, it looks as below




  1. Describe the cucumber scenario
  2. Data Excel
  3. Combine cucumber scenario outline + data table to specify multiple data sets
  4. Consume Data Helper and parse data
  5. Execute the scenario
  6. Observe the results
  7. Closing thoughts and Project Code


1) Describe Cucumber scenario

We will:

  1. open website
  2. Then click “Contact us” button at the right top corner, which will take us to contact form.
  3. On the contact form, select heading, set email, set order reference number, set message
  4. We will input all the necessary values and eventually click submit.

The simple cucumber scenario when written might look as below. I want to use the data from row “1” of the excel workbook and I would go with the default workbook i.e. default.xlsx.

2) Data Excel

We will use the data excel ‘src/test/resources/testData/default.xlsx’ file and the file looks as below [We will post the entire project codebase at the end of this section in case you want to download the excel file]. We are also printing the current data set used by the scenario inside step_definitions, so that we know which data set was used.


3) Cucumber Scenario Outline

The second cucumber scenario outline uses multiple data sets and repeats the operations for each data set. This is just to show how data “drives” the test case execution.


4) Consume Data helper and parse data

We create a class, that has a method that takes excel file path and sheet name as inputs and spits out a List of HashMaps , otherwise we call it datamap here.


Entire Cucumber Scenario:

Step Definitions

Execution Output

The last scenario will fail because we are trying to access a hashmap from datamap that is out of bounds. So that is expected

Intellij execution output (How to execute explained in previous post)



Command line output (mvn test)


CI Server output