This is a example how to use SpecFlow and SpecFlow+Runner to run Selenium Web Tests for different Browsers.
The example is based on https://github.com/baseclass/Contrib.SpecFlow.Selenium.NUnit
This example also takes a screenshot after each step and embeds the screnshot in the final report. Refer to the documentation here for an explanation of how the screenshot's path is passed to the report.
There is an article covering this project here.
3 Targets are defined here, one for each browser. The targets have a filter applied so that only those scenarios tagged for a particular browser are executed by the target (using "@Browser_IE", "@Browser_Chrome", "@Browser_Firefox").
Deployment transformations steps are configured:
- IISExpress: This starts an IIS Express instance, saving you from manually needing to check it is running
- EnvironmentVariable (once per target): This sets the environment variable Test_Browser to the desired browser name
This driver provides you access to the appropriate Selenium WebDriver. It uses the aforementioned environment variable Test_Browser value for this, which is set in the target configuration. To get access to the Selenium Web Driver, use the Current property on it. Use Context Injection to get the instance.
Here are the scenarios defined.
To get a scenario executed for a browser, add a tag Browser_{BrowserName} to the scenario/scenario outline/feature.
Example for a scenario for all 3 browsers:
@Browser_Chrome
@Browser_IE
@Browser_Firefox
Scenario: Basepage is Calculator
Given I navigated to /
Then browser title is Calculator