-1

i'm doing a test with Selenium on my PC with windows:

System.setProperty("webdriver.chrome.driver", "src\\test\\java\\resources\\chromedriver.exe");

it work correctly if i run test inside project with eclipse. But when i package into jar my project include also test\java\resources\chromedriver.exe and put this jar and load jar in my project it dont load driver:

java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/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:847) ~[na:na]
etc....

How i must set path in project Selenium for load driver?

UPDATE: i must test it on Unix Machine Thanks Regards

Catanzaro
  • 1,312
  • 2
  • 13
  • 24

1 Answers1

-1

You can e.g. extract the chromedriver.exe or chromedriver (depending on the host OS) from your JAR on runtime and then pass the extracted chromedriver's file path via

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

See this question.

BullyWiiPlaza
  • 17,329
  • 10
  • 113
  • 185