Search code examples
c#seleniumselenium-webdriverselenium-grid2

Problems with setting up Selenium Grid2


I want to study how to run same test at same time on two computers. I've done everything that is explained in this tutorial. I have PC, where I set hub:

java -jar selenium-server-standalone-2.37.0.jar -role hub

And I have notebook, where is node:

java -jar selenium-server-standalone-2.37.0.jar -role webdriver -hub http://192.168.0.50:4444/grid/register -port 5566

So here is my code:

public class Driver
{
    IWebDriver _driver = new ChromeDriver(@"C:\Program Files (x86)\ChromeDriver\");

    public string BaseUrl, NodeUrl;
    [SetUp]
    public void Setup() 
    {
        BaseUrl = "http://google.com/";
        NodeUrl = "http://192.168.0.66:5566/wd/hub";
        DesiredCapabilities capability = DesiredCapabilities.Chrome();
        capability.SetCapability(CapabilityType.BrowserName, "chrome");
        capability.SetCapability(CapabilityType.Platform, "VISTA");
        _driver =  new RemoteWebDriver(new Uri(NodeUrl), capability);
    }

    [TearDown]
    public void Teardown()
    {
        _driver.Quit();
    }
    [Test]
    public void SimpleTest()
    {
        _driver.Navigate().GoToUrl(BaseUrl);
        Assert.AreEqual("Google", _driver.Title);
    }
}

When I run test in VS2012, it gives me following error:

SetUp : System.InvalidOperationException : The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list

I searched. People gave advice to add environment variable from Control Panel in Windows. I did.

webdriver.chrome.driver C:\Program Files (x86)\ChromeDriver\chromedriver.exe

That didn't help me. Same error. I searched more. Next advice was to set this variable when I configure hub. Like this:

java - jar selenium-server-standalone-2.37.0.jar webdriver.chrome.driver="C:\Program Files(x86)\ChromeDriver\chromedriver.exe" -role hub

This also doesn't help. What should I do?


Solution

  • IT should be

    java - jar selenium-server-standalone-2.37.0.jar -Dwebdriver.chrome.driver="C:\Program Files(x86)\ChromeDriver\chromedriver.exe" -role hub