如何在jar中设置属性webdriver.chrome.driver,"......")但在Unix环境中?



我正在我的windows电脑上用Selenium做一个测试:

System.setProperty("webdriver.chrome.driver", "src\test\java\resources\chromedriver.exe");

如果我使用eclipse在项目内部运行测试,它就会正常工作。但当我把我的项目打包到jar中时,还包括test\java\resources\chromedriver.exe,并把这个jar和加载jar放在我的项目中,它不会加载驱动程序:

java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
at com.google.common.base.Preconditions.checkState(Preconditions.java:847) ~[na:na]
etc....

我必须如何在项目Selenium中为负载驱动程序设置路径?

更新:我必须在Unix机器上测试谢谢问候

例如,您可以在运行时从JAR中提取chromedriver.exechromedriver(取决于主机操作系统(,然后通过传递提取的chromedriver的文件路径

System.setProperty("webdriver.chrome.driver", "...");

请参阅此问题。

相关内容

最新更新