Reputation: 31
I'm now using specflow+selenium webdriver with unit test provider mstest to do automation test on multi browsers. Currently, I have some scenarios and they can be executed on different browsers such as IE, Chrome and Firefox. In order to test 3 browsers I have to write the scenario 3 times each with a tag on it.
@ie
Scenario: IE Using valid user to login
Given I have navigated to the login page
And I type the 'username' and 'password'
When I click login button
Then I should see the home page
@chrome
Scenario: Chrome Using valid user to login
Given I have navigated to the login page
And I type the 'username' and 'password'
When I click login button
Then I should see the home page
@firefox
Scenario: Firefox Using valid user to login
Given I have navigated to the login page
And I type the 'username' and 'password'
When I click login button
Then I should see the home page
Now, the testcases are same only with different browser. There's too much redundant code. So I want to only write one Scenario with multi tags for different browser and let it generate 3 tests as below.
@ie
@chrome
@firefox
Scenario: Using valid user to login
Given I have navigated to the login page
And I type the 'username' and 'password'
When I click login button
Then I should see the home page
How can I do it? or is there any other solutions? Thanks!
Upvotes: 3
Views: 1416
Reputation: 5835
I am not sure if this is possible in plain MSTest.
But your usecase is one, why the SpecFlow+Runner was created.
Have a look at this example: https://github.com/techtalk/SpecFlow.Plus.Examples/tree/master/SeleniumWebTest
This implements your requirements by using the SpecFlow+Runner.
Full disclosure: I am one of the developers of SpecFlow+ (Runner/Excel).
Upvotes: 3
Reputation: 174
create a excel sheet of test cases with you testdata of username and password and also mention in which browser you want to run, the you can write a script of fetching data from excel sheet, by writing it in switch case, can create case of different browsers.
Upvotes: 2