如何在 Nunit/Selenium GRID/C# 设置中使用多个浏览器
我有一个 Selenium GRID 设置,上面有各种浏览器(IE6、7、8、FF 3.5.6),用 C# 编写,它们单独工作得很好。我还有一套 Selenium 测试设置,它们也可以在我传递给它们的环境中正常工作。我要求的是一种以编程方式设置不同单元测试的方法,以循环访问 Selenium GRID 上可用的所有浏览器。
浏览器并不多,因此浏览器列表或数组之类的东西很好,但我无法找到一种方法来通过浏览器进行安装和拆卸循环。我使用 C# 和 NUnit 以及连接到它的 Selenium Grid 和 3 个 Selenium RC。
如果这意味着我可以在浏览器中循环,我什至不介意更改为 MbUnit 之类的东西。
非常感谢
I have a Selenium GRID Setup with the various browsers on it (IE6, 7, 8, FF 3.5.6) written in C# and individually they work fine. I also have a set of Selenium Tests setup and they also work fine with the envirments that i pass to them. What i am asking for is a way to prgrammatically set the differant unit tests to cycle through all of the browsers available to it on the Selenium GRID.
There are not that many browsers, so things like a list or array of browsers is fine but i can't figure a way to have the Setup and TearDown cycle through the browsers. I am using C# with NUnit along with Selenium Grid and 3 Selenium RCs hooked upto it.
I Don't even mind changing to something like MbUnit if it meant I could cycle through the browsers.
Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一种(相当丑陋的)选项可能是在目标浏览器中传递的测试方法上使用 RowTest 扩展 - 其代价是通过设置污染实际的测试方法,并可能减慢整个测试套件的速度。
One (rather ugly) option might be using RowTest extension on test methods passing in the target browsers - at a prize of polluting the actual test methods with setup and probably slowing down the whole test suite.
如果您使用
MbUnit
,则可以将Factory
属性绑定到变量。然后让数据工厂
为您想要自动化的每种类型的浏览器返回一次。它将为每个浏览器执行一次测试。http://www.gallio.org/wiki/doku .php?id=mbunit:data-driven_testing:factory
If you are using
MbUnit
, you can bind a theFactory
attribute to a variable. Then have theData Factory
return once of each type of browser you want to automate with. It will execute the tests once per browser.http://www.gallio.org/wiki/doku.php?id=mbunit:data-driven_testing:factory
如果您使用 NUnit,则可以指定 参数化 TextFixtures 以及所有您想要在基本测试类中使用的浏览器:
并且测试本身将类似于:
2)您可以通过 PNunit。缺点:每个测试都应该在 test.conf 文件中提及。优点:所有指定的浏览器将并行运行。 test.conf 文件示例,其中为两个浏览器指定了一个测试:
基本测试类将类似于:
3) 您可以在 app.config 中指定浏览器并通过 TeamCity 更改它。没有研究这个解决方案,所以不能给你一个例子。
希望前两个解决方案会有所帮助。
If you use NUnit, you can specify parameterized TextFixtures with all browsers you want at base test class:
And tests itself will be something like that:
2) You can specify browsers via PNunit. Cons: each test should be mentioned in test.conf file. Pros: all specified browsers will be run in parallel. Example of test.conf file with one test specified for two browsers:
And base test class will be something like that:
3) You can specify browsers in app.config and change it via TeamCity. Didn't investigate this solution, so can't give you an example.
Hopes first two solutions will help.