.net - 针对远程浏览器执行 Selenium 2 测试

标签 .net nunit remoting selenium-webdriver

我想要一个配置,其中我的构建服务器运行一个 NUnit 测试,该测试在远程机器上打开并驱动浏览器。实现这一目标的最佳方法是什么?

在 Selenium 1 中很容易做到,因为 Java 代理服务器位于您的测试和浏览器之间。在 Selenium 2 中,您的测试直接与浏览器通信(至少在 IE 和 Firefox 中)。

有没有好的方法可以做到这一点?可能与 WCF 服务或什么?

最佳答案

您需要从 http://code.google.com/p/selenium/ 获取独立 Selenium 服务器(当前为 selenium-server-standalone-2.0a6.jar)。 .然后从远程机器上的命令行开始(你需要在那里安装 Java):
java -jar selenium-server-standalone-2.0a6.jar
还有一个 .NET implementation of the server ,但它的版本落后于 Java 版本

那么你应该使用 RemoteWebDriver :

IWebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),DesiredCapabilities.InternetExplorer());

然后像在“本地”测试中一样使用驱动程序

更多信息:

http://code.google.com/p/selenium/wiki/RemoteWebDriver

http://www.google.com/codesearch/p?hl=en#CJyJMZi8hYc/trunk/remote/client/src/csharp/webdriver-remote/RemoteWebDriver.cs

http://code.google.com/p/selenium/wiki/RemoteWebDriverServer

关于.net - 针对远程浏览器执行 Selenium 2 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3886659/

相关文章:

asp.net - .NET Remoting vs. Web Services vs. Windows Communication Foundation (WCF)

.net - 运行 Visual Studio 2010 实例并以编程方式附加到进程?

.net - ObjectStateManager 中已存在具有相同键的对象。现有对象处于未更改状态

c# - 如何通过解析具有相同命名常量的另一个枚举来获取枚举值

c# - 用于查询事件网络和关联连接的 WMI

c# - 如何从远程存储库获取 pull 状态/最新状态?

unit-testing - 如何对此进行单元测试?

selenium - 海狸鼠截图

c# - 改进大量测试用例的测试语法

.net-2.0 - 当消息变大时,IpcChannel Remoting变慢