使用 Webinator+Selenium、SpecFlow 和 NUnit 进行多浏览器测试

Multiple Browsers Tests using Webinator+Selenium, SpecFlow and NUnit(使用 Webinator+Selenium、SpecFlow 和 NUnit 进行多浏览器测试)

本文介绍了使用 Webinator+Selenium、SpecFlow 和 NUnit 进行多浏览器测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Selenium 驱动程序开发一个带有 WebinatorSpecFlow+NUnit 的 ASP.NET MVC 3 应用程序.我在使用 Chrome(使用 chromedriver)和 Internet Explorer 运行并行测试时遇到问题.

I'm developing an ASP.NET MVC 3 app with WebinatorSpecFlow+NUnit using the Selenium driver. I'm having a problem running parallel tests with Chrome (using chromedriver) and Internet Explorer.

每当我通过 Webinator 在同一个会话中运行两个测试并由 Selenium 并行运行时,当我向页面发送任何点击操作时,IE 似乎都会挂起.

Whenever I have both tests running in the same session and in parallel by Selenium via Webinator, IE seems to hang when I send any click action to the page.

我无法使用此处建议的解决方案,因为 SpecFlow 会自动生成底层 C# 代码.我的解决方案的设计类似于 this(完整代码可作为要点提供):

I'm not able to use the solution suggested here, since SpecFlow generates the underlying C# code automatically. My solution is designed like this (the full code is available as a gist):

_multipleBrowsers.RunTest(web => web.GoToUrl("http://localhost/PROJECT/Authentication/Registration"));

我会为每个需要测试的浏览器实例化一个新的 IWebManager.然后,我使用浏览器实例调用委托操作.它是这样的:

What happens is that I instantiate a new IWebManager for every browser I need to test. Then, I call the delegate action, using the browser instance. It goes like this:

        foreach (var web in _webManagers)
        {
            Debug.WriteLine("Running test with " + web.Config.Browser);

            action(web);
        }

这样测试几乎可以并行运行.它会弹出一个浏览器,执行操作,然后是另一个浏览器,依此类推.

This way the tests run almost in parallel. It pops up a browser, execute the action, then the other browser, and so forth.

关于如何克服这个 ChromeDriver 问题有什么想法吗?我应该使用 SpecFlow 更改针对多个浏览器的测试方法吗?

Any thoughts on how to overcome this ChromeDriver issue? Should I change my testing approach with SpecFlow for multiple browsers?

参考资料:

  • Webinator
  • specflow
  • nunit
  • ChromeDriver

推荐答案

你可以更简单 只使用

然后你用标签@Browser:IE编写功能

Then you write feature with tag @Browser:IE

@Browser:IE
@Browser:Firefox
Scenario: Add comments
       Given I navigated to /guinea-pig
       And I have entered 'This is not a comment' into the commentbox
       When I press 'submit' 
       Then my comment 'This is not a comment' is displayed on the screen

目前是我发现的最佳解决方案,因为它也可以在所有浏览器中进行测试,但在您需要的特定浏览器中进行测试

For now is the best solution which i found since it also make sence to test not in all browsers but in specific which you need

这篇关于使用 Webinator+Selenium、SpecFlow 和 NUnit 进行多浏览器测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:使用 Webinator+Selenium、SpecFlow 和 NUnit 进行多浏览器测试

基础教程推荐