specflow tutorial step by step

Step Definition File

The next aim test or run the feature data file and test the feature record. The Step definition file required writing the execution or explanation of Definition Data file in C Clear. When SpecFlow executes a Part of a Scenario. it will choose a matching Step Explanation to execute 

SpecFlow Step Definition file

A Step Definition data file the small little bit of code with a pattern mounted on it or quite. Step Meaning a C# method in a category with an annotation above it. An annotation accompanied by the pattern employed to web page link matching Steps. the code SpecFlow will install when it perceives a Gherkin Keywords.

How to Build a Step Definition document?

It will always be good to have a nice and clean folder composition in the project. each folder signifies this content in it. So, first generate a folder for the Step Classification file. Make a Step Definition Data file Folder 1) Create a fresh Folder by right click on the 'Task' and navigating to include -> New Folder. 2) Name the folder as 'Steps' and struck enter.

Build a Step Definition File

1) The color of the statements talked about in the feature file is violet. This means these statements don't have any definition attached to it. It is very easy to put into practice all the steps. Right-click on feature file in the code editor. choose to Generate Step Definitions from the popup menu. 2) This display a POP-UP window. that may ask to choose the statements for Step Definition document created. Select all and select Generate button. Don't forget to give it a rational name. In this case, I named it as 'Login_Steps', as all the steps in this will record related to end user Login. 3) It will ask to identify the folder path to save the Step Definition file. As a new Steps folder created to keep the definition file. Speak about the path for the same folder with the name of the Steps document. In this case, I have named it as 'LogIn_Steps'. Struck Save button to move forward. 4) All the claims in the feature documentary will change the color now. it means these Feature statements associated with Step Definitions. 5) To have a go through the attached definitions, click on any assertion and press F12 button. This starts the linked explanation record and cursor directed to the associated definition.

Step Meaning method Implementation

This stuff is actually easy if you know how to work with Selenium. The last SpecFlow Feature Data file, straightforward case of LogIn features. Now start picking right up the code from the same Selenium Test Script and fit it into SpecFlow steps.

Add Selenium C# code to the Step Definition methods

1) Take the code for pursuing steps and fit it into the first approach to Step Definition Record: 'Given User is at the Home Site'.

  • Kick off the Browser
  • Navigate to Home Page

2) Take the code for pursuing step and fit it into the second approach to Step Definition Data file: 'And Navigate to LogIn Web page'.

  • Click on the Log in link

3) Take the code for the following step and fit it into the second method of Step Definition Data file: 'When User gets into UserName and Security password'.

  • Enter Account

4) Take the code and fit it into the second method of Definition Data file: 'And Go through the Log in button'.

  • Click on Submit button

5) Take the code for the following step and fit it into the second method of Step Definition Record: 'Then Successful LogIN communication should screen'.

  • LogOut Button displayed
Run the SpecFlow Selenium Test 

The following steps are useful for How to run the Specflow Selenium test,

  1. To recognize all the test in the Feature File, go to check -> Windows -> Test Explorer.
  2. Notice, at the kept side a new window appeared called Test Explorer.
  3. Now to run an attribute Test. Right-click on the Test Explorer home window and choose Run Selected Assessments. This may run the determined test and screen the output in the gaming system window.