In my selenium tests, I have the path to ChromeDriver hardcoded with
System.setProperty("webdriver.chrome.driver", "C:\\Users\\kday\\Desktop\\Selenium Stuff\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
However, this means that when I export the program as a runnable jar file, that the test will not work since it cannot find the hardcoded path (if it is on another computer). Is there any way to make it so that either..
a.) - ChromeDriver is part of the jar and runs with it
b.) - I can initialize it in the code without hardcoding the value in like that
Mostly, I want all the tests to run (in IE, Chrome, FF) by just running the jar.
Better yet, you can import the driver as a Jar instead of a .exe
The jar is here.
http://www.java2s.com/Code/Jar/s/Downloadseleniumchromedriver20a4jar.htm
You can add a Chrome driver folder under the project then use
System.getProperty("user.dir");
to return the project path and then use a relative path to find the driver.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With