1

I am getting this error:

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. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html at com.google.common.base.Preconditions.checkState(Preconditions.java:197) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:110) at org.openqa.selenium.chrome.ChromeDriverService.access$0(ChromeDriverService.java:1) at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:118) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:291) at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:82) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:117) at selenium.basics.Chrome.chromeBrowser(Chrome.java:16) at selenium.basics.Firefox.main(Firefox.java:8)

dnlcrl
  • 5,022
  • 3
  • 32
  • 40
Pavan Kumar
  • 203
  • 2
  • 3
  • 7
  • 1
    Have you tried installing the chromedriver as it suggests? – Sean F Apr 22 '15 at 04:35
  • 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. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html – Chip Dean Apr 22 '15 at 04:35
  • Duplicate of [Selenium using Python - Geckodriver executable needs to be in PATH](https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path) and [Selenium using Java - The path to the driver executable must be set by the webdriver.gecko.driver system property](https://stackoverflow.com/questions/38676719/selenium-using-java-the-path-to-the-driver-executable-must-be-set-by-the-webdr) – cachius May 22 '22 at 22:17

7 Answers7

4

user5899853 Try this:

System.setProperty("webdriver.chrome.driver" ,  "/Users/sampada/Applications/chromedriver");

And:

@BeforeClass
public static void init() {
driver = new ChromeDriver(); //init chrome driver
driver.get("http://google.com”); //url of website we like to test
Saganowsky
  • 103
  • 1
  • 10
2

Download the latest chrome version from

http://chromedriver.storage.googleapis.com/index.html

Path should be adjusted through build path.

Try it once, it is helping to you...

ruffin
  • 16,507
  • 9
  • 88
  • 138
nalini
  • 112
  • 5
1

You can use brew to install chromedriver and keep it up-to-date:

brew install chromedriver
Michelin Man
  • 1,013
  • 8
  • 9
  • It's actually placed in a cask: `brew cask install chromedriver` – Mads Y Apr 03 '19 at 09:36
  • Just an update to the above comment, brew now disables the above command. From brew: > Error: Calling `brew cask install` is disabled! Use brew install [--cask] instead. – Craig Wayne Feb 04 '21 at 08:10
0

Extract the chrome/firefox driver executable to Applications folder and follow the below code.

This should work for you :

System.setProperty("webdriver.chrome.driver", "/Applications/chromedriver");
WebDriver driver = new ChromeDriver(); 
0

Just run the below in terminal:

brew cask install chromedriver
Ganesh Manickam
  • 2,113
  • 3
  • 20
  • 28
Bharathi
  • 69
  • 2
  • Just an update to the above brew now disables the above command. From brew: > Error: Calling `brew cask install` is disabled! Use brew install [--cask] instead. – Craig Wayne Feb 04 '21 at 08:11
0

Spent a few good hours trying to get Selenium/Chrome to work on my Mac.

The obvious:

  • Download the selenium driver from this location: https://www.seleniumhq.org/download/
  • Open the zip file and add client-combined-#VERSION#.jar to the included jars of your project.

What I was missing:

  • Add the jars that are under the libs directory of the selenium sources you just downloaded as well.

Hope this helps

Yishai Landau
  • 620
  • 4
  • 14
0

1. You can check the current chromedriver version: chromedriver --version

2. Install via command line: https://formulae.brew.sh/cask/chromedriver

brew install --cask chromedriver

3. Be careful if your chrome version is not the same https://sites.google.com/chromium.org/driver/downloads

4. Add this driver to your selenium code

System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");

enter image description here

Leo N
  • 126
  • 2
  • 5