DataSource attribute with Specflow for multiple browser testing DataSource attribute with Specflow for multiple browser testing selenium selenium

DataSource attribute with Specflow for multiple browser testing


You could use a web driver abstraction framework to write driver agnostic test code. To do this I've used Coypu. Using this library you can easily switch between different web drivers (e.g. Selenium, Phantom JS, WaitN) without needing to write different driver code.

In a web driver factory class you could then use code like (see here for more information):

sessionConfiguration.Driver = Type.GetType("Coypu.Drivers.Selenium.SeleniumWebDriver, Coypu");sessionConfiguration.Browser = Drivers.Browser.Parse("firefox");

to get an instance of Selenium for FireFox or you could replace "firefox" with "chrome" to get an instance of Chrome.

I've used this approach to run a suite of tests for different browsers and it worked well. However this has meant executing a suite of tests for one browser, and then upon completion running them for another.


Best is to use Baseclass.Contrib.SpecFlow.Selenium.NUnit dll.

see the Example:

@Browser:IE@Browser:Chrome@Browser:Firefox

Scenario Outline: Add Two Numbers

You can use @Browser:.......... in your feature file. This attribute will list 3 tests in your test explorer for each browser and you can run whichever you wanted to use.

For detailed information , go here.