Saturday, January 20, 2018

Data Driven Testing using Scenario Outline in Cucumber

We have seen on way of Data Driven Testing in Data Driven Testing without Scenario Outline. Another way to perform Data Driven Testing in Cucumber is using 'Scenario Outline'. "Scenario Outline" is a keyword, if a test needs to be executed for more than one test data set it will be marked as "Scenario Outline" instead of "Scenario".

The only difference between 'Scenario' and 'Scenario Outline' is, 'Scenario Outline' comes along with a keyword called 'Example' using which the test data sets are represented in data table format.

Consider the same scenario which we been using in our tutorial, now let us automated the same test with different test data sets.

Step 1: Write the scenario using 'Scenario Outline' keyword as below

Observe that, Scenario Outline is having a red underline. Place the cursor on it, compiler telling us that 'Examples' keyword is missing. Remember that 'Scenario Outline' should always be associated with Example keyword.

Step 2: Press 'Alt+Enter' and select 'Create Example Section'.

You should see 'Examples' keyword being added after the steps as below

Step 3: Now let us modify the steps. Write down the parameter names in the <> symbol in the steps. And use same names as column names in the Examples table as shown below

Step 4:  Write the step definitions for the modified steps as we seen in the previous posts.

Here the arguments are not added automatically we need to write them manually. Also the parameter names should be converted as regular expression. Please check below screenshot

Step 5: If the step definitions are written properly, the Scenario Outline could look like below. The parameters appear in purple color.

Step 6: Now add the different test data sets in the table as below

In the above screenshot, I am running the our scenario for two test data sets Google and Facebook in Firefox and Chrome browsers.

Step 7: Run the tests and checkout the results

Both Scenario and Scenario Outline are executed. And Scenario Outline is executed for two data sets.

That is all about achieving data driven using Scenario Outline. Please comment your queries ans suggestions on this pots. Thanks for reading!!

#qababu #HappyLearning #HappyTesting


  1. Thanks for sharing valuable information and it is useful for onlineitguru provides the best selenium Online Training

  2. Really very informative and creative contents. This concept is a good way to enhance the knowledge of Autocad.thanks for sharing please keep it up
    Software Testing Training in Gurgaon

  3. I really enjoy the blog.Much thanks again. Really Great selenium Online course

  4. I am Just Learning All the topics of Selenium Grid Through this blog.Very Thankful for this blog and also my respect to the author of blog.

  5. Hi,
    i am working with protractor with cucumber so i want to execute one scenario with multiple test data. i created feature file with one scenario outline and examples.
    i provided 4 different test data in example. when i execute my test case my test is passed with 4 test scenarios but i am able to only 3 test cases on ui page not all 4
    but test is passed.
    i am not getting what is my problem.

  6. Wondering how? In the first place, by being the creator of the problem – the volume, the velocity and the variety of data. Data Analytics Courses

  7. Build sophisticated applications leveraging the security of Amazon Web Services Cloud with the aid of our Amazon Web Services Certification Training Program. The course preps you for the AWS Solution Architect Associate certification exam. Master AWS Cloud Architecture, AWS EC2 services, AWS S3 services, AWS RDS and network service requirements and much more in this course.

  8. Hey, thanks for this great article I really like this post and I love your blog and also Check marking analytics manager in hyderabad at 360DIGITMG.
    360Digitmg marketing analytics manager in hyderabad

  9. I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page!

    data science course


Selenium4: Working with two parallel windows in Selenium Automation

A new method newWindow() is introduced in Selenium 4 (Alpha). Using this method we can open a new tab or new window from the current window...