7

Everything works fine with Firefox, but I can't start chrome. I'm on linux, using php webdriver bindings.

require_once "/usr/local/src/selenium/php-webdriver-bindings-0.9.0/phpwebdriver/WebDriver.php";
putenv("PATH=".getenv("PATH").':'.'/usr/local/src/selenium/chrome_webdriver/'); //Prepare for chrome

$webdriver = new WebDriver("localhost", "4444");
//$webdriver->connect("chrome");
$webdriver->connect("chrome","",array(
    'webdriver.chrome.driver'=>'/usr/local/src/selenium/chrome_webdriver/chromedriver',
    ));

The error message I get is "The path to the chromedriver executable must be set by the webdriver.chrome.driver system property". As you can see, I've tried setting that in the desiredCapabilities array, but that must be the wrong place. I can see in the selenium logs that my setting is getting through as this log line shows:

INFO - Executing: [new session: {javascriptEnabled=true, webdriver.chrome.driver=/usr/local/src/selenium/chrom..., browserName=chrome, nativeEvents=false, version=}] at URL: /session)

I start selenium with java -jar selenium-server-standalone-2.21.0.jar

I'm using Chromium v.18.

I created a shortcut /usr/bin/google-chrome that points to /usr/bin/chromium-browser

I can start chromedriver manually with no problems. It says:

port=9515
version=20.0.1133.0

Having that running, or not, does not make any difference to the error message selenium gives me.

UPDATE: Related question: selenium 2 chrome driver (answer there is for java, not php)

Community
  • 1
  • 1
Darren Cook
  • 27,837
  • 13
  • 117
  • 217
  • 1
    Can you try passing the webdriver.chrome.driver value while starting the server? Like java -Dwebdriver.chrome.driver = pathtochromedriver -jar selenium-server.jar – A.J May 30 '12 at 21:44
  • @A.J Yes! Could you move your answer to an answer so I can mark it correct, please. – Darren Cook May 30 '12 at 23:27
  • You're using the code for Java. It is not supported in PHP. – Moradnejad Nov 29 '16 at 07:00

2 Answers2

14

You can try passing the webdriver.chrome.driver property from commandline while starting the selenium server. Like this:

 java -Dwebdriver.chrome.driver = pathtochromedriver -jar selenium-server.jar

I am not sure about the reason why the other one is not working. You need to check whether its really setting the system property from code..

A.J
  • 4,929
  • 2
  • 27
  • 36
  • Thanks, confirmed that this works. I guess that _system properties_ and webdriver _desiredCapabilities_ are different things. – Darren Cook May 31 '12 at 07:44
  • 1
    The `-Dwebdriver...` lines must be set **before** `selenium-server.jar` is called, otherwise it will not open a Chrome browser and instead open Firefox by default (at least, mine was). – Ben Oct 01 '13 at 02:27
  • Im facing the Could not find the load main clas error when i hit above mentioned command in my command line . – Suresh Kumar Amrani Jul 15 '15 at 13:38
3

Without any blanks it worked for me on WinXP32:

java -Dwebdriver.chrome.driver=C:\chromedriver.exe -jar selenium-server.jar
ingobaab
  • 87
  • 4