2017-07-06 54 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”

让我知道这是否解决您的问题。

相关问题