How do I get chrome working with selenium, using php webdriver?

13,500

Solution 1

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..

Solution 2

Without any blanks it worked for me on WinXP32:

java -Dwebdriver.chrome.driver=C:\chromedriver.exe -jar selenium-server.jar
Share:
13,500
Darren Cook
Author by

Darren Cook

I'm data scientist, software developer, computer book author, entrepreneur. I'm director at QQ Trends, a company that solves difficult data and software challenges for our clients. Lots of machine learning, especially NLP-related, recently. (We sometimes have freelance projects, so get in touch if interested.) (Contact me at dc at qqtrend dot com: please mention you are coming from StackOverflow, so I know it is not spam.) My first book was "Data Push Apps with HTML5 SSE", with O'Reilly, 2014 (ISBN: 978-1449371937). Old by computer standards, but the standard has been stable, so surprisingly still useful. My second book, at the end of 2016, also with O'Reilly, was Practical Machine Learning with H2O (ISBN: 978-1491964606). I'm British, speak English and Japanese (fairly fluent, 1 kyu), with a bit of German, Chinese and Arabic. As for computer languages, I've done commercial work in most of them; but it has been mostly JavaScript, R, Python, C++ the past five years. All my Stack Overflow and all my Stack Exchange contributions (across all sites) are dedicated to the public domain or available under the CC0 license at your choice. I don't like viral licenses. Easy ways to irritate me on StackExchange sites (whether my own question or someone else's): 1. Downvote without a comment (N/A if someone already left a comment and you just agree with it, of course); 2. Answers in comments. Other than that I'm an easy-going and pragmatic guy :-)

Updated on July 03, 2022

Comments

  • Darren Cook
    Darren Cook almost 2 years

    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)