SeleniumGroopie
SeleniumGroopie

Reputation: 241

Using Chrome Driver with Selenium 2

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.

Upvotes: 19

Views: 84037

Answers (7)

Vikram
Vikram

Reputation: 7525

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());

Upvotes: 0

prabhakar
prabhakar

Reputation: 51

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);

}

Upvotes: 5

Jobet Samuel
Jobet Samuel

Reputation: 56

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.

Upvotes: 1

Mike Kwan
Mike Kwan

Reputation: 24477

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");

Upvotes: 14

sebarmeli
sebarmeli

Reputation: 18275

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.

Upvotes: 4

trimper
trimper

Reputation: 471

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)

Upvotes: 44

AutomatedTester
AutomatedTester

Reputation: 22438

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

Upvotes: 2

Related Questions