gpt4 book ai didi

selenium-webdriver - 如何使用specflow+selenium webdriver+mstest做多浏览器测试?

转载 作者:行者123 更新时间:2023-12-01 11:23:53 24 4
gpt4 key购买 nike

我现在使用 specflow+selenium webdriver 和单元测试提供商 mstest 在多浏览器上进行自动化测试。目前我有一些场景,可以在IE、Chrome、Firefox等不同的浏览器上执行。为了测试 3 种浏览器,我必须将场景编写 3 次,每次都带有一个标签。

@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 个测试。

@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

我该怎么做?或者还有其他解决方案吗?谢谢!

最佳答案

我不确定这在普通 MSTest 中是否可行。
但是您的用例是一个,为什么要创建 SpecFlow+Runner。

看看这个例子:https://github.com/techtalk/SpecFlow.Plus.Examples/tree/master/SeleniumWebTest

这通过使用 SpecFlow+Runner 实现了您的要求。

完全披露:我是 SpecFlow+ (Runner/Excel) 的开发者之一。

关于selenium-webdriver - 如何使用specflow+selenium webdriver+mstest做多浏览器测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39339828/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com