selenium Grid2和c#如何设置和运行

本文关键字:设置 运行 何设置 Grid2 selenium | 更新日期: 2023-09-27 18:04:23

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

运行selenium hub

java -jar ..'DLL'Selenium'selenium-server-2.1.0'selenium-server-standalone-2.1.0.jar -role hub

但后来我不知道如何运行3硒浏览器。

i try like

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();

但是在驱动程序对象上,我得到这个错误:无法找到:{platform=WINDOWS, browserName=firefox, version=5.0}

关于如何并行运行3个硒浏览器有很多不好的文档。

Thx

selenium Grid2和c#如何设置和运行

您需要在启动集线器之后启动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

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

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

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

ISelenium selenium = new DefaultSelenium("localhost", 4444, "firefox", "http://localhost/");
selenium.Start();

注意,browsername中没有*。

如果你打算使用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();

关于如何启动节点的文档可以在这里找到,如何使用remotewebdriver可以在这里找到