Anupama Kota
Anupama Kota

Reputation: 13

Launch chrome browser

I am trying to launch chrome browser (version 26.0) using webdriver. I am getting the following error message.

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. 
    at com.google.common.base.Preconditions.checkState(Preconditions.java:176)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:105)
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:69)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:107)
    at googleSearch.main(googleSearch.java:13)

Code I used:

driver = new ChromeDriver();
driver.navigate().to("http://www.google.com/");

I use mac 10.8.2.

Upvotes: 0

Views: 15234

Answers (4)

Danger
Danger

Reputation: 2113

For this to work, you need to:

  1. Install Chrome
  2. Install Chrome Web Driver
  3. Make sure you have the chrome web driver in you path, for example on Windows something pointing to chromedriver2_win32_0.8. You can put that in your path by either: (a) Modifying your windows path environment variable, or; (b) adding the following to your java command line options:
    -Dwebdriver.chrome.driver='/path/to/driver'

In case of using selenium grid -Dwebdriver.chrome.driver='/path/to/driver' has to be added while creating a node from command line.

Upvotes: 5

alchemist
alchemist

Reputation: 1081

1) In case of using selenium without GRID:

 System.setProperty("webdriver.chrome.driver","/absolute/path/to/chromedriver");
 driver =  new ChromeDriver();

does the job.

2) In case of using selenium with GRID:

System.setProperty("webdriver.chrome.driver","/absolute/path/to/chromedriver");
driver =  new ChromeDriver();

And from command line, while creating a node for chrome browser one needs to pass

-Dwebdriver.chrome.driver='/absolute/path/to/chromedriver'

The above two changes did the job for me, apart from this I was getting this libnss3.so not found error which I solved by creating a symlink of libnss3.so present in /usr/lib/x86_64-linux-gnu/ folder to /usr/lib/

ln -s /usr/lib/x86_64-linux-gnu/libnss3.so /usr/lib/libnss3.so

PS: Also make sure that you are using 64bit OR 32bit version of chrome driver as per your system.

Upvotes: 1

Yash Varshney
Yash Varshney

Reputation: 375

change the permission of file and then run your code again. Open command prompt and navigate to directory where your chrome exe exists and write

chmod 777 filename

Hope it will solve your problem.

Upvotes: 0

luksch
luksch

Reputation: 11712

For chrome to work with selenium-webdriver you need to have not only a working chrome browser installed, but also the chromedriver executable. Note that these are TWO different executable files that both need to be specified.

Upvotes: 0

Related Questions