How to run my selenium runnable jar in a different machine without driver files



  • 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");
    


  • 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.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2