Wednesday, March 1, 2017

How to write multiple test cases in Selenium with Cucumber?

In this post we will learn about writing multiple test cases (Scenarios) in a Feature file. This post is going to be an extension to the previous post First Test Case in Selenium with Cucumber. So please go through it to understand the current post better. Let's get started step by step...

Step 1: This time we are taking "Gmail valid login validation" as our test. Please copy the below code snippet in our feature file created "gmailLogin.feature" file and save it.

Step 2: Now go to Right click > Run As > Junit Test

Step 3: Check out the Junit results, The first scenario is executed and passed but the second scenario is stopped at the 3rd step in the second scenario and failed. This because the last three steps are missing in the Step Definitions.

In the console we will find the three missed steps, add the three in step definitions file and define their functionalities.

Step 4: Add the steps in Step Definition file and define their actions.

Step 5: Go to Right click > Run As > Junit Test.

Step 6: Check out the Junit results now, two scenarios are executed successfully and are Passed also.

This is how we can add multiple tests in the feature file. And we need not execute all the scenarios for adding a new scenario. Comment all the previous scenarios > add the new scenario and run it as Junit test > add missed step definitions. That's how we can add the multiple scenarios.


  1. Thanks for providing the information . The articles in your blog helped me a lot for improving the knowledge on the subject. Also check my small collection on this at selenium Online Training Hyderabad blog

  2. Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful while being straight forward and to the point.
    Selenium certification training


Java Program 6: How to reverse a String in Java?

In this post we will discuss different methods to reverse a String in java programming. Method 1: Step 1: Read the input string using ...