如何使用specflow + selenium webdriver + mstest在多浏览器上进行测试? [英] How to use specflow+selenium webdriver+mstest to do test on multi browser?
问题描述
我现在将Specflow + Selenium Webdriver与单元测试提供程序mstest一起使用,以在多个浏览器上进行自动化测试. 目前,我有一些方案,它们可以在不同的浏览器(例如IE,Chrome和Firefox)上执行.为了测试3个浏览器,我必须编写3个场景,每个场景都带有一个标签.
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
现在,测试用例仅在不同的浏览器上是相同的.冗余代码过多.因此,我只想针对不同的浏览器编写一个带有多个标签的方案,并使其生成3个测试,如下所示.
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!
推荐答案
我不确定在纯MSTest中是否可行.
但是您的用例是一个,为什么要创建SpecFlow + Runner.
I am not sure if this is possible in plain MSTest.
But your usecase is one, why the SpecFlow+Runner was created.
请看以下示例: https://github.com/techtalk/SpecFlow.Plus.Examples/tree/master/SeleniumWebTest
这通过使用SpecFlow + Runner满足您的要求.
This implements your requirements by using the SpecFlow+Runner.
完全公开:我是SpecFlow +(Runner/Excel)的开发人员之一.
Full disclosure: I am one of the developers of SpecFlow+ (Runner/Excel).
这篇关于如何使用specflow + selenium webdriver + mstest在多浏览器上进行测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!