Remote Webdriver Chrome throws a "path to the driver executable" error

Anand S picture Anand S · Mar 4, 2013 · Viewed 10.4k times · Source

Hi when i use the following code

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

I get the follwing error

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 TearDown : System.NullReferenceException : Object reference not set to an instance of an object. at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) at Testframework.Browser.RemoteGoto(String browser, String url) in Browser.cs: line 86 at Testframework.CommonAction.RemoteBrowser(String browser) in CommonAction.cs: line 70 at Test.RegistrationTest.InvalidRegistrationTest(String browser, String username, String password, String confirmPassword, String securityQuestion, String securityAnswer, String errorMessageText, String firstname, String lastname) in RegistrationTest.cs: line 50 --TearDown at Testframework.CommonAction.CaptureScreen(String fileName) in CommonAction.cs: line 121 at Test.RegistrationTest.SnapshotOnFailure() in RegistrationTest.cs: line 590

Answer

Arran picture Arran · Mar 4, 2013

The clue really is in the error.

Chrome should be installed on the system where the tests are either running on or being pointed to.

Take a step back, look at the documentation:

https://code.google.com/p/selenium/wiki/ChromeDriver

Also, if Chrome is installed in a peculiar place, you'll need to point Selenium to it's location. Again, this is explained in the documentation.

In C#:

DesiredCapabilities capabilities = DesiredCapabilities.Chrome();
capabilities.SetCapability("chrome.binary", this.binaryLocation);

or:

ChromeOptions options = new ChromeOptions();
options.BinaryLocation = "pathtogooglechrome";
capabilities.SetCapability(ChromeOptions.Capability, options);