Pavan Kumar
Pavan Kumar

Reputation: 253

How to run Selenium WebDriver test cases in Chrome in MAC OS?

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)

Upvotes: 3

Views: 33171

Answers (7)

Leo N
Leo N

Reputation: 164

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

Upvotes: 2

nalini
nalini

Reputation: 112

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...

Upvotes: 2

Yishai Landau
Yishai Landau

Reputation: 630

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

Upvotes: 0

Bharathi
Bharathi

Reputation: 69

Just run the below in terminal:

brew cask install chromedriver

Upvotes: 0

Michelin Man
Michelin Man

Reputation: 1053

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

brew install chromedriver

Upvotes: 2

Nitin Shinde
Nitin Shinde

Reputation: 1

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

Upvotes: 0

Saganowsky
Saganowsky

Reputation: 113

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

Upvotes: 4

Related Questions