SpecFlow is the .Net version of Cucumber. This is a Behavior development framework for .Net. Here we will show how we can implement our Selenium Webdriver script using SpecFlow framework.
Test Case : Verify the search Functionality of Google Search page
Step One : Installing IDE integration package for SpecFlow
Step Four : Add Selenium Webdriver reference from nuget.org
Selenium WebDriver package is displayed at Search list.
Click on Install button.
Latest WebDriver will be installed and added as Reference.
Step Five : Create a Feature file and write test case steps using gherkin syntax
Scenario: Verify the search Functionality of Google Search page
Given : It describes the precondition to execute test steps.
When : It describes the steps to perform the test.
Then : It describes the expected result.
In our case, Given clause will be,
Given I navigate to the page "www.google.com" And I see the page is loaded
Note that we an “And” operator to write multiple clauses.
When clause will be,
When I enter Search Keyword in the Search Text box | Keyword | | SpecFlow | And I click on Search ButtonNote that here we write data table for search keyword where we use “Keyword” as the table column name and “SpecFlow” is the data.
Then clause will be,
Then Search items shows the items related to SpecFlowNow the Feature file looks like,
Step Six : Write code for every step
Note that we do not need to write any comment here as Methods name describes the steps. This is the contribution BDD.
Here we just verify that appropriate page is loaded.
Note that we use list of data in our feature file that SpecFlow converts to table. We can use it as normal Row/Column concept.
This is the power of SpecFlow using BDD.Lot more new things are coming…