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 TestRunner.java 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 TestRunner.java 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.

14 comments:

  1. Replies
    1. I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts. Python Projects for Students Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account. Project Center in Chennai

      Delete
  2. 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

    ReplyDelete
  3. 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

    ReplyDelete
  4. Individuals will become a skilled writer only writing and writing some more. Further, writing is not a linear process. It is messy and frequently, time consuming.resume template

    ReplyDelete
  5. Write my Paper I am impressed. I don't think Ive met anyone who knows as much about this subject as you do. You are truly well informed and very intelligent. You wrote something that people could understand and made the subject intriguing for everyone. Really, great blog you have got here.

    ReplyDelete
  6. Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. type my essay

    ReplyDelete
  7. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. essay writing services

    ReplyDelete
  8. Good Post! , it was so good to read and useful to improve my knowledge as an updated one, keep blogging.After seeing your article I want to say that also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts likethis. https://www.3ritechnologies.com/course/sap-online-training-certification-course/

    ReplyDelete
  9. Good Post! , it was so good to read and useful to improve my knowledge as an updated one, keep blogging.After seeing your article I want to say that also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts likethis. https://www.3ritechnologies.com/course/aws-online-training/

    ReplyDelete

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...