Selenium 如何使用Gecko驱动程序启动Mozill浏览器

Selenium 如何使用Gecko驱动程序启动Mozill浏览器,selenium,Selenium,我开始学习Selenium(第5天)并使用Gecko驱动程序启动Mozilla,但出现以下错误: Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: C:\dev\geckodriver.exe at com.google.common.base.Preconditions.checkState(Preconditions.java:199)

我开始学习Selenium(第5天)并使用Gecko驱动程序启动Mozilla,但出现以下错误:

Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: C:\dev\geckodriver.exe
    at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
    at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:121)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:116)
    at org.openqa.selenium.firefox.GeckoDriverService.access$000(GeckoDriverService.java:37)
    at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:95)
我复制了代码(在eclipse中重新键入):

我的Geckodriver路径是C:\dev\Geckodriver
我看到同样的问题被问了多次,但没有看到上面的信息。

你需要从link下载
geckodriver.exe
,没有gecko驱动程序,你无法运行firefox 49.0。下载后,将其解压缩并存储在计算机上的任何位置,然后按照以下代码进行操作。为此,请使用Selenium版本3.0.1。 如果您使用的是旧版本的selenium,则必须使用

WebDriver driver = new MarionetteDriver(); 
代替

WebDriver driver = new FirefoxDriver();
从以下链接下载gecko驱动程序:


谢谢Kinjal,我已经从相同的链接()下载了geckodriver,并在我的目录c:\dev中解压。我还在system.setproperty中放置了相同的路径。System.setProperty(“webdriver.gecko.driver”,“C:\\dev\\geckodriver.exe”);但我收到的信息是“驱动程序可执行文件不存在:C:\dev\geckodriver.exe”,即使我可以在那里导航并查看文件。您使用的是哪个版本的selenium JAR?
WebDriver driver = new FirefoxDriver();
System.setProperty("webdriver.gecko.driver","C:\\dev\\geckodriver.exe"); // you have to select you path of gecko driver where you placed it after download and unzip.
WebDriver driver = new FirefoxDriver();

driver.get("http://www.gmail.com");