Vitali Plagov
Vitali Plagov

Reputation: 762

selenium-java dependency set in Maven, but Selenium asks for the path to the driver

I've set selenium-java dependency in Maven:

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.7.1</version>
</dependency>

But When I run a simple test - I get an exception that the path to the driver is not set: The path to the driver executable must be set by the webdriver.chrome.driver system property

Setting up the Maven dependency isn't it enough for Selenium? What I'm missing that Selenium can't read Maven dependency?

Upvotes: 0

Views: 643

Answers (1)

alainlompo
alainlompo

Reputation: 4434

Setting up the Maven dependency isn't it enough for Selenium?

No, you need to tell it where to find the web driver in this using something like:

System.setProperty("webdriver.chrome.driver", complete_path_to_your_chrome_driver_executable_here);

should fix the issue.

You can do a similar configuration in your pom.xml directly by defining a property in the properties section that contains your path and by using systemPropertyVariables in the configuration section of maven-surefire-plugin.

For example:

Create in properties section of your pom.xml

<webriver.path>path_to_your_driver_executable</webriver.path>

Then add a systemPropertyVariables section in the configuration section of your maven-surefire-plugin

<systemPropertyVariables>
   <webdriver.chrome.driver>${webriver.path}</webdriver.chrome.driver>
   [...]
</systemPropertyVariables>

Upvotes: 1

Related Questions