2017-07-06 55 views
-2

收到以下錯誤異常線程「main」 java.lang.IllegalStateException:驅動程序可執行文件不存在:/Users/Golcha/Desktop/Automation/geckodriver.exe

異常線程「main」 java.lang.IllegalStateException:驅動程序 可執行文件不存在: /Users/Golcha/Desktop/Automation/geckodriver.exe

代碼:

import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 

public class selenium{ 

    private static WebDriver driver; 

    public static void main(String[]args){ 

     System.setProperty("webdriver.gecko.driver","Users/Golcha/Desktop/Automation/geckodriver.exe"); 

     setDriver(new FirefoxDriver()); 
    } 

    public static WebDriver getDriver() { 
     return driver; 
    } 

    public static void setDriver(WebDriver driver) { 
     selenium.driver = driver; 
    } 

} 
+0

請不要在標題中添加整個錯誤信息。 – demouser123

回答

0

嘗試下面的代碼,但在執行下面的代碼之前好好檢查的geckodriver的路徑,或者我會建議你粘貼geckodriverC驅動器或任何其他驅動器,使您的路徑簡單,如下一個:

System.setProperty("webdriver.firefox.marionette", "C:\\geckodriver.exe"); 

它應該沒有任何問題。祝一切順利 !

+0

非常感謝你..當我編輯這部分webdriver.firefox.marionette –

0

我的事情你有沒有在你的System.setProperty()方法中所提到的Geckodriver完整(完整的)路徑。你已經錯過了盤符「C」

「C:/Users/Golcha/Desktop/Automation/geckodriver.exe」

讓我知道這是否解決您的問題。

相關問題