9

I am trying to run my Selenium tests against Chrome. When I initialize driver locally:

@driver = Selenium::WebDriver.for( :chrome )

Everything works fine (I already put Chrome binary on my PATH) But when I try to launch it remotely:

@driver = Selenium::WebDriver.for(:remote, :url => 'http://' + SELENIUM_HOST + port + webdriver_hub, :desired_capabilities => :chrome)

I get the following error

Selenium::WebDriver::Error::UnhandledError: The path to the chromedriver 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/chromium/downloads/list (java.lang.IllegalStateException)

I am a bit confused there - how exactly should I set this system property? I found this code written in Java:

DesiredCapabilities caps = DesiredCapabilities.chrome();
caps.setJavascriptEnabled(true);
caps.setCapability("chrome.binary", "/path/to/where/chrome/is/installed/chrome.exe");
System.setProperty("webdriver.chrome.driver","/path/to/where/you/ve/put/chromedriver.exe");
ChromeDriver driver = new ChromeDriver(caps);

but my tests are written in Ruby. RubyBindings don't talk about this issue http://code.google.com/p/selenium/wiki/RubyBindings

Ahmad F
  • 30,560
  • 17
  • 97
  • 143
Yulia
  • 1,575
  • 4
  • 18
  • 27

4 Answers4

16

Actually the error message is slightly wrong. You don't have to set the system property, but the chromedriver executable needs to be available in the PATH on the remote machine (where the server is running).

If you want to specify the path as a property, you can do that when you launch the server, e.g.:

java -Dwebdriver.chrome.driver=/path/to/driver -jar selenium-server-standalone.jar
jarib
  • 6,028
  • 1
  • 24
  • 27
1

You have to set path to your cromedriver.exe inside the code of the test. Its something like

System.setproperty();

in Java

I am also using Java based tests, so I cannot give you exact example for Ruby. But basically you have to tell your Ruby program where is the path to chromedriver.exe

Pavel Janicek
  • 14,128
  • 14
  • 53
  • 77
  • Thanks for the tips, Pavel. But it is exactly what I am looking for - how to set up this property in Ruby. – Yulia Aug 03 '11 at 05:37
  • I am not Ruby expert, so I dont have clue... But after some searching I found this question: http://stackoverflow.com/questions/2348621/ruby-setting-property-values-when-initializing-object Is that helpful? If not, maybe consider asking Ruby specific question – Pavel Janicek Aug 03 '11 at 07:20
1

Okay, guys. With the help I could find the answer. Check it out.

That is how you set up the driver on your local machine:

    @driver = Selenium::WebDriver.for(:remote, :chrome :url => 'http://' + SELENIUM_HOST + port + webdriver_hub, :desired_capabilities => browser)

where

browser = ':chrome'
port = ':4444'
webdriver_hub = '/wd/hub'

On the remote machine running the server would be something like this

    java -jar selenium-server-standalone-2.2.0.jar -Dwebdriver.chrome.driver="path/to/where/you/put/chromedriver.exe"

After run your tests from the local machine.

Best of luck!

Yulia
  • 1,575
  • 4
  • 18
  • 27
0

I found the selected answer to be very misleading. It took me about an hour to release the mistake in it. The node is the one that should have the webdriver.chrome.driver property set, not the hub.

Therefore the selected answer's command should instead be:

java -Dwebdriver.chrome.driver=/path/to/driver -jar selenium-server-standalone.jar -role node

nebffa
  • 1,529
  • 1
  • 16
  • 26