开发者

selenium Grid2 and C# howto setup and run

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

i run selenium hub with

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

but then i do not know how to run 3 selenium browsers.

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 = n开发者_运维技巧ew RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability);

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

but on driver object i get this error: cannot find : {platform=WINDOWS, browserName=firefox, version=5.0}

there is so bad docs on this how to run 3 selenium browser in paralell.

Thx


You need to launch the RC node after launching the hub. You can use the command:

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

This will launch the RC node with default capability of running 5 firefox browsers, 5 googlechrome and 1 IE browser.

You can check the grid console to make sure your RC got registered. Grid console URL will be http://localhost:4444/grid/console. Hover your mouse on top of each of the browser icon to find the browsername which you should use inside the code and to find other properties of browser.

If you are trying to run the existing selenium 1 tests in Grid 2.0 you don't need the capability matcher. You just need to have

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

Note that there is no * with browsername.

If you are planning to use webdriver to run the tests in grid, then you need to modify your code 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 WebDriverBackedSelenium(driver,"baseURL");
selenium.Start();

Documentation on how to start the nodes can be found here and how to use remotewebdriver can be found here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜