Search code examples
grailsselenium-webdrivergeb

Grails, Geb, Selenium w/ Chrome: Unable to Connect?


Problem

My selenium functional test is failing when I run using the Chrome driver, but works when using Firefox.

My Environment

  1. Mac OS X Mountain Lion
  2. Chrome Version 22.0.1229.94
  3. Build info: version: '2.2.1', revision: '16551', time: '2012-04-11 21:42:35'
  4. System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.2', java.version: '1.6.0_35' Driver info: driver.version: ChromeDriver

Steps to Reproduce

The exception occurs when using the Geb Grails example application from github.

Run the application using the Chrome driver:

grails -Dgeb.env=chrome test-app

The tests will begin to run, an instance of Chrome is successfully opened, but nothing happens afterwards. The Chrome browser isn't directed to a url, it just sits there with a silly grin on its face. The below error is thrown in the console after a 15 second (or so) timeout.

The Error

Caused by: org.openqa.selenium.WebDriverException: Unable to either launch or connect to Chrome. 
Please check that ChromeDriver is up-to-date. Using Chrome binary 
at: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome 

My Debugging Steps

  1. Per this stackoverflow post, I've attempted various different versions of the driver with no effect.
  2. The tests are successful when using the Firefox driver (sadly, I must test with Chrome).
  3. Attempt to use the latest beta of chrome Version 23.0.1271.40 beta. no luck.
  4. Upgraded the geb and selenium versions in the test app to latest and greatest: def gebVersion = "0.7.2" def seleniumVersion = "2.25.0"

Humble Thanks Section

Thanks for taking a look at this. I'd love to adopt geb, but its been an uphill battle to date.


Solution

  • Might be a silly answer but did you install the chrome driver? http://code.google.com/p/selenium/wiki/ChromeDriver

    For Firefox, you don't need to install a driver but for Chrome and IE, you do. That may be why your tests are running using FF and not chrome.

    Good luck!