將geckodriver放置在資源中並將其映射到正在工作的機器上,但不在任何其他機器上。我需要它將其導出到其他機器,以便我創建一個需要在任何其他機器上運行的jar,但是在其他機器上運行該jar時拋出「驅動程序可執行文件的路徑必須由webdriver.gecko.driver系統屬性「錯誤。在intellij中爲壁虎驅動程序設置相對路徑拋出錯誤
public static WebDriver createDriver()
{
WebDriver driver= new FirefoxDriver();
System.setProperty("webdriver.gecko.driver", "./src/main/resources/geckodriver");
driver = new FirefoxDriver(FirefoxDriverProfile());
driver.manage().window().maximize();
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
return driver;
[Please take a look at the image]
https://i.stack.imgur.com/khGBu.png
可能的複製(http://stackoverflow.com/questions/38676719/selenium-java-the-path-to-the-driver-executable-must-the-by-the-webdr) – Andersson