Search code examples
javaseleniumjvm-argumentsselenium-chromedriver

Troubles setting path to Chromedriver


I have Chrome and chromedriver installed on a remote machine we use to run Selenium tests. I'm am getting the execption when attempting to run tests on chrome:

org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property;

These tests run correctly on Firefox on the same machine. My code to setup ChromeDriver looks like this:

DesiredCapabilities capability = DesiredCapabilities.chrome(); System.setProperty("webdriver.chrome.driver", "/usr/lib/chromium-browser/chromedriver"); this.driver = new RemoteWebDriver(new URL("http://"+this.testIP+":4444/wd/hub"), capability);

I verified the path to chromedriver is correct on the test machine and I can manually start it without any issues.

Anyone know why I'm getting that exception?


Solution

  • I've not used Selenium in the way you are using it very often, but to do what you are doing I'd expect having to start Selenium like this on the server so that the system property is set on the server:

    java -Dwebdriver.chrome.driver=/usr/lib/chromium-browser/chromedriver -jar selenium-server-standalone-2.31.0.jar [etc...]
    

    What I see you doing is setting the system property on the client side.