我想将资源文件夹中的文件路径设置为系统属性。
String path = MainCore.class.getClassLoader().getResource("chromedriver-76.0.3809.68.exe").toExternalForm();
System.out.println(path);
//file:/D:/JavaIDEA/projname/target/classes/chromedriver-76.0.3809.68.exe
System.setProperty("webdriver.chrome.driver", path);
//IllegalStateException: The driver executable does not exist:
//D:\JavaIDEA\projname\file:\D:\JavaIDEA\projname\target\classes\chromedriver-76.0.3809.68.exe
为什么我setProperty
会在我的路径前添加项目路径?
我也尝试过这样做:path = path.replace("/", "\\\\");
-同样的结果
我正在使用Windows。
答案 0 :(得分:2)
尝试
debugger;