How to create remote Webdriver for Chrome

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

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

Everything works fine (I already installed the Chrome binary on my PATH), but when I try to run 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: path to chromedriver executable file must be set 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'm a little confused - 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 do not talk about this issue http://code.google.com/p/selenium/wiki/RubyBindings

+8
ruby google-chrome selenium webdriver
source share
4 answers

Actually, the error message is somewhat incorrect. You do not need to set the system property, but the chrome executable must be accessible in PATH on the remote computer (where the server is running).

If you want to specify the path as a property, you can do this at server startup, for example:

 java -Dwebdriver.chrome.driver=/path/to/driver -jar selenium-server-standalone.jar 
+14
source share

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

 System.setproperty(); 

in java

I also use Java based tests, so I cannot give you an exact example for Ruby. But basically you should tell your Ruby program where the path to chromedriver.exe is located

+1
source share

Ok guys. With the help I could find the answer. Check this.

This is how you configure the driver on the local computer:

  @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 computer the server is running on, there will be something like this

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

After running the tests from the local machine.

Good luck

+1
source share

I found the selected answer very misleading. It took me an hour to issue an error. node is the one that should have the webdriver.chrome.driver property, not a hub .

Therefore, the selected response command should be:

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

0
source share

All Articles