19
votes

I'm trying to use Chrome Drive to execute some of my tests, which are working perfectly with Firefox, but I'm not being able to execute them, I'm already verified the requirements, which are the location of Chrome, Version 12 or higher, and things like that, but anyway still not working correctly, the way to call the driver is:

WebDriver fd = new ChromeDriver();
fd.get("url");

and then searching some elements, but nothing is working, the error message is:

Exception in thread "main" org.openqa.selenium.WebDriverException: Couldn't locate Chrome. Set webdriver.chrome.bin System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_18' Driver info: driver.version: ChromeDriver at org.openqa.selenium.chrome.ChromeBinary.getChromeBinaryLocation(ChromeBinary.java:220) at org.openqa.selenium.chrome.ChromeBinary.getCommandline(ChromeBinary.java:121) at org.openqa.selenium.chrome.ChromeBinary.prepareProcess(ChromeBinary.java:67) at org.openqa.selenium.chrome.ChromeBinary.start(ChromeBinary.java:109) at org.openqa.selenium.chrome.ChromeCommandExecutor.start(ChromeCommandExecutor.java:373) at org.openqa.selenium.chrome.ChromeDriver.startClient(ChromeDriver.java:65) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:85) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:25) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:43) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:53) at equifax.qa.test.NewTests.access.main(access.java:11)

Please if anyone can help me would be great.

7
This stacktrace is from an older version of Selenium, before the ChromeDriver rewrite. Some of the classes shown no longer exists. The advice given below assumes you're on a newer version.jarib
Do you know how to do this from Python? When I use Firefox I do the following: If there a python module for chrome? from selenium import selenium import unittest, time, re class Untitled(unittest.TestCase): def setUp(self): self.verificationErrors = [] self.selenium = selenium("localhost", 4444, "*chrome", "mysite.com/") self.selenium.start()Rudiger Wolf
Figured out my question above. I can replace "*chrome" with *firefox, *mock, *firefoxproxy, *pifirefox, *chrome, *iexploreproxy, *iexplore, *firefox3, *safariproxy, *googlechrome, *konqueror, *firefox2, *safari, *piiexplore, *firefoxchrome, *opera, *iehta, *customRudiger Wolf
I am using groovy? How to give this for groovy?ChanGan
I have the same issue, actually I posted my question in here stackoverflow.com/questions/18436156/… I am very confused ... Is it the problem with the Selenium, chromedriver or what?CHEBURASHKA

7 Answers

44
votes

I was able to get this to work by launching the selenium server like this:

java -jar selenium-server-standalone-2.0rc2.jar -Dwebdriver.chrome.driver=c:\path\to\chromedriver.exe

(Running Windows 7 64bit, Chrome 12, selenium server rc2)

14
votes

Download the ChromeDriver.exe from http://code.google.com/p/selenium/downloads/list then add the system property like so:

System.setProperty("webdriver.chrome.driver", "...\chromedriver.exe");
5
votes

Use this for Chrome

Step-1 Download Chrome driver from location

Step-2 Use Testng Framework

@BeforeClass

public void setUp() throws Exception

{ 

    System.setProperty("webdriver.chrome.driver", "D://Work-Selenium//chromedriver_win32//chromedriver.exe");

    driver = new ChromeDriver();

    baseUrl = "http://google.com";

    driver.get(baseUrl);

}
4
votes

Just download the chromedriver_win32_13.0.775.0.zip and selenium-server-standalone-2.0rc3.jar from [http://code.google.com/p/selenium/downloads/list][1]

Unzip the chromedriver_win32_13.0.775.0.zip into a folder, Eg. C:/drivers/chrome/, so that the chromedriver.exe is located at C:/drivers/chrome/chromedriver.exe.

Register the node against the hub on port 6668 (for example)

java -jar selenium-server-standalone-2.0rc3.jar -role webdriver -hub http://hubUrlHostname:4444/grid/register -port 6668 -browser "browserName=chrome,version=13.0,platform=windows" -Dwebdriver.chrome.driver=C:\drivers\chrome\chromedriver.exe

If you access to

http://hubUrlHostname:4444/grid/console

you should see the Chrome driver registered.

2
votes

Have you made sure that you have downloaded the Chrome driver from http://code.google.com/p/selenium/downloads/list and placed it in your PATH?

have a look at http://code.google.com/p/selenium/wiki/ChromeDriver for more details

1
votes

You can set the capabilities to point to the binary of the browser to be launched.

DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability("chrome.binary", "/usr/lib/chromium-browser/chromium-browser");

WebDriver driver = new ChromeDriver(capabilities);

For ex:- Chromium Browser(33.0.1729.0 )works fine with ChromeDriver 2.7 and not the with the older ones.

You can choose from all the chromedriver version available from the link below:- http://chromedriver.storage.googleapis.com/index.html

So try to use the browser version supported by the chromedriver.

0
votes

If you are using Maven Project. Follow the below steps

  1. Download the latest chromedriver.exe from this link.
  2. Create a drivers folder in test. It should look like this src/test/resources/drivers
  3. Move the chromedriver.exe to the above path in step 2
  4. Use the below code for before creating chrome driver object

System.setProperty("webdriver.chrome.driver", Thread.currentThread().getContextClassLoader().getResource("drivers/chromedriver.exe").getFile());