0

I am trying to export my project as a runnable jar and run it without driver.exe files being present. I tried incorporating them with below code to make it independent but still unable to run the jar file without driver files being presenting in the same folder.

code:

String currentDir=System.getProperty("user.dir");

System.setProperty("webdriver.chrome.driver", currentDir+File.separator+"chromedriver.exe");

1 Answer 1

1

You can use WebDriverManager for this purpose:

You can download the dependency by Gradle:

dependencies {
    testCompile("io.github.bonigarcia:webdrivermanager:3.6.1")
}

Then on the code, you just need to setup the driver and create the driver objects:

WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();

You can find details about driver version here.

2
  • Thank you so much. Worked like a charm!!! :)
    – Venky
    Jun 24, 2019 at 4:47
  • Most welcome. Could you mark the answer as accepted? Jun 24, 2019 at 5:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.