Specflow Tutorial
Introduction to SpecFlow Installation of SpecFlowWriting first SpecFlow test in Visual Studio Writing step definitions for a SpecFlow feature file Executing SpecFlow scenarios and feature files Using SpecFlow runner to execute the feature files Using tags in SpecFlow Passing parameters to steps Data table in SpecFlow Scenario Background Scenario outline Hooks in SpecFlow Executing Selenium tests with SpecFlow Executing the failed test multiple times Sharing selenium Webdriver instance in SpecFlow Writing to SpecFlow HTML reportsSpecflow Datatable
We can also pass the data in the form of Data table as shown in below feature file.
Feature: Datatable in SpecFlow
@datatable
Scenario: Datatable Scenario 1
Given I am on the web page "https://www.softpost.org/selenium-test-page/"
And I enter below information in the form
| first name | last name | id |
| Paul | Watson | 29292 |
| Shaun | Watson | 64545 |
Here is the step definition class for above scenario. Note that parameter in the method is of type Table and we can read data from Datatable using TableRow class.
using System;
using TechTalk.SpecFlow;
namespace SpecFlowRunnerProject
{
[Binding]
public class DatatableInSpecFlowSteps
{
[Given(@"I enter below information in the form")]
public void GivenIEnterBelowInformationInTheForm(Table table)
{
foreach (TableRow row in table.Rows)
{
foreach (String value in row.Values)
Console.WriteLine(value);
}
}
}
}
Here is the output of above scenario.Web development and Automation testing
solutions delivered!!