0

Below is my code which works perfect in Eclipse Java Project

    String IEPath = "src/IEDriverServer.exe";
    File file = new File(IEPath);
    System.setProperty("webdriver.ie.driver",file.getPath());
    WebDriver driver = new InternetExplorerDriver();

If I export the same code to a runnable JAR file and double click it or if I run it from command prompt gives below exception

    The driver ececutable does not exist C:\Backup\New folder\src\IEDriverServer.exe

I have copied IE exe inside my Java Project and have exported the Java Project including the IE exe. When I run the JAR, it is failing to pick the IE exe path. Please help! TIA!

1 Answers1

0

You have two options here:

  1. Read the resource inside the jar. See more info here.

  2. Use WebDriverManagerto automate the management of IEDriverServer.exe.

For alternative 2, simply import the WebDriverManager library in your project and change your code:

String IEPath = "src/IEDriverServer.exe";
File file = new File(IEPath);
System.setProperty("webdriver.ie.driver",file.getPath());

... by:

InternetExplorerDriverManager.getInstance().setup();
Community
  • 1
  • 1
Boni García
  • 4,306
  • 5
  • 25
  • 43