0 votes
1 view
in Devops and Agile by (18.3k points)

So I have read all the docs on adding chromedriver to my path and followed all of them. I am on a Mac with Selenium2, maven, eclipse, and all the latest drivers:

Error:

The path to the chromedriver executable must be set by the webdriver.chrome.driver system property;

I put chromedriver in my Applications folder and my path looks like:

echo $PATH  

/Users/tcerrato/selenium/BS_Sel_Project/auto_helper/test_scripts:/usr/local/apache-maven-2.2.1//bin:/Users/oracle/oracle/product/10.2.0/db_1/bin:/opt/local/bin:/opt/local/sbin:/Applications:

What am I missing? I cannot run with chrome driver at all. Any help would be great I'm trying random stuff now.

Here is my pom section on selenium:

<dependency>

    <groupId>org.seleniumhq.selenium</groupId>

    <artifactId>selenium</artifactId>

    <version>2.0rc2</version>

    <type>pom</type>

</dependency>

<dependency>

    <groupId>org.seleniumhq.selenium</groupId>

    <artifactId>selenium-chrome-driver</artifactId>

    <version>2.5.0</version>

</dependency>

<dependency>

    <groupId>org.seleniumhq.selenium</groupId>

    <artifactId>selenium-firefox-driver</artifactId>

    <version>2.6.0</version>

</dependency>

1 Answer

0 votes
by (48.8k points)

Add this dependency to your project:

<dependency>

   <groupId>io.github.bonigarcia</groupId>

   <artifactId>webdrivermanager</artifactId>

    <version>3.6.2</version>

</dependency>

This library downloads the latest version of the WebDriver binary you'd need and export the proper Java system variable (webdriver.chrome.driver, webdriver.gecko.driver, webdriver.opera.driver, phantomjs.binary.path, webdriver.edge.driver, webdriver.ie.driver), simply using one of the following sentences respectively:

WebDriverManager.chromedriver().setup();

WebDriverManager.firefoxdriver().setup();

WebDriverManager.operadriver().setup();

WebDriverManager.phantomjs().setup();

WebDriverManager.edgedriver().setup();

WebDriverManager.iedriver().setup();

...