Using Google Chrome for Behat and Selenium2 Testing

This is rather quick. First of all, you need a fully working Behat and Selenium2 setup working, using Firefox as default. Once you achieved this, we can change it to use Google Chrome.

First, download chromedriver at https://code.google.com/p/selenium/wiki/ChromeDriver and put it somewhere like /data/lib/chromedriver. Once done, we run our Selenium2 java jar file like this:

java -jar selenium-server-standalone-2.44.0.jar -Dwebdriver.chrome.driver="/data/lib/chromedriver"

Then in our behat.yml file, we set the browser setting like this.

            base_url: someurl
            goutte: ~
            default_session: goutte
            javascript_session: selenium2
            browser_name: 'chrome'
                node_modules_path: 'somepath...'
                capabilities: { "browserName": "chrome", "browser": "chrome", "version":  "29", 'chrome': {'switches':['--no-sandbox']}}

That’s it. It should launch Chrome instead of Firefox.

1 Comment

1 thought on “Using Google Chrome for Behat and Selenium2 Testing”

  1. if you get an exception : reverse the order , so instead of adding -Dwebdriver in the end , add it directly after the -jar , then write the selenium jar

    java -jar -Dwebdriver.chrome.driver=”/data/lib/chromedriver” selenium-server-standalone-2.44.0.jar

Leave a reply

Your email address will not be published. Required fields are marked *