selenium Grid2和C#howto设置和运行

sen*_*ale 5 c# selenium

http://code.google.com/p/selenium/wiki/Grid2
Run Code Online (Sandbox Code Playgroud)

我用硒运行

java -jar ..\DLL\Selenium\selenium-server-2.1.0\selenium-server-standalone-2.1.0.jar -role hub
Run Code Online (Sandbox Code Playgroud)

但后来我不知道如何运行3个selenium浏览器.

我尝试了

DesiredCapabilities capability = DesiredCapabilities.Firefox();
capability.SetCapability(CapabilityType.Platform, "WINDOWS");
capability.SetCapability(CapabilityType.BrowserName, "firefox");
capability.SetCapability(CapabilityType.Version, "5.0");

IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability);

ISelenium selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost/");
selenium.Start();
Run Code Online (Sandbox Code Playgroud)

但在驱动程序对象上我收到此错误:找不到:{platform = WINDOWS,browserName = firefox,version = 5.0}

关于如何在paralell中运行3个selenium浏览器有如此糟糕的文档.

谢谢

A.J*_*A.J 3

启动 hub 后需要启动 RC 节点。您可以使用命令:

java -jar selenium-server-jar -role rc (OR -role wd - depending upon whether you need webdriver or remotecontrol) -hub http://localhost:4444/grid/register
Run Code Online (Sandbox Code Playgroud)

这将启动 RC 节点,默认能够运行 5 个 firefox 浏览器、5 个 googlechrome 和 1 个 IE 浏览器。

您可以检查网格控制台以确保您的 RC 已注册。网格控制台 URL 将为http://localhost:4444/grid/console。将鼠标悬停在每个浏览器图标的顶部,可以找到您应该在代码中使用的浏览器名称,并找到浏览器的其他属性。

如果您尝试在 Grid 2.0 中运行现有的 selenium 1 测试,则不需要功能匹配器。你只需要拥有

ISelenium selenium = new DefaultSelenium("localhost", 4444, "firefox", "http://localhost/");
selenium.Start();
Run Code Online (Sandbox Code Playgroud)

请注意,浏览器名称中没有 *。

如果您计划使用 webdriver 在网格中运行测试,那么您需要修改代码,例如:

DesiredCapabilities capability = DesiredCapabilities.Firefox();
capability.SetCapability(CapabilityType.Platform, "WINDOWS");
capability.SetCapability(CapabilityType.BrowserName, "firefox");
capability.SetCapability(CapabilityType.Version, "5.0");

IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability);

ISelenium selenium = new WebDriverBackedSelenium(driver,"baseURL");
selenium.Start();
Run Code Online (Sandbox Code Playgroud)

有关如何启动节点的文档可以在此处找到,如何使用remotewebdriver可以在此处找到