如何将ChromeDriver加入JAR? [英] How can I include ChromeDriver in a JAR?
问题描述
System.setProperty(webdriver.chrome.driver,Drivers / chromedriver.exe);
它工作正常。但是,当我尝试导出它(使用Eclipse的标准导出)。它崩溃,我相信,因为它找不到ChromeDriver(我认为这是因为导出它与FirefoxDriver工作正常)。 我尝试将.JAR更改为.ZIP以查看内部,我看到驱动程序
文件夹被剥离,只需在顶级JAR中放入 chromedriver.exe
。我尝试将属性更改为 System.setProperty(webdriver.chrome.driver,chromedriver.exe);
但仍然崩溃。
有谁知道为什么导出的JAR无法找到 chromeDriver
,尽管事实上我已经证实它在JAR中?
谢谢,
丹尼尔
这是在罐子里,但不能被执行(与从zip文件中运行.exe相同),您必须在运行它之前解压缩它。
I'm writing a web-automation program and so far, it works fine using Selenium's FirefoxDriver. However, I want to make it use Chrome if Firefox is not installed. I downloaded the ChromeDriver, put it inside a folder in my Eclipse project, and ran it. After I added System.setProperty("webdriver.chrome.driver", "Drivers/chromedriver.exe");
it worked fine. However, when I try to export it (using Eclipse's standard Export). It crashes, I believe because it can't find the ChromeDriver (I think this because exporting it with FirefoxDriver works fine).
I have tried changing the .JAR to a .ZIP in order to look inside, and I see that the driver
folder was stripped away, simply putting chromedriver.exe
inside the top-level JAR. I tried changing the property to System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
but still crashes.
Does anyone know why the exported JAR is unable to find chromeDriver
, despite the fact that I have verified that it is in the JAR?
Thanks, Daniel
It's in the Jar but cannot be executed (same as trying to run an .exe from a zip file), you have to extract it before running it
这篇关于如何将ChromeDriver加入JAR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!