无法安装geckodriver.exe

时间:2016-09-21 03:29:51

标签: java selenium bots

我想以bot方式填写网络表单。我在文档中添加了libraryclient-combined 3.0.0 beta 3。我的firefox版本应该最新。

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

public class Selenium {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {



WebDriver driver=new FirefoxDriver();

driver.get("https://mail.google.com");
driver.findElement(By.id("Email")).sendKeys("yourEmailId");
driver.findElement(By.id("Passwd")).sendKeys("yourPassword");
driver.findElement(By.id("signIn")).click();

}

}

然而,错误出现了。

据我了解,seleniums 3.0 jar版本应与geckodriver一起使用。然后,我尝试在这里安装geckodriver v10.0。

https://github.com/mozilla/geckodriver/releases

当我执行geckodriver-v0.10.0-win64.zip时,安装程​​序无法安装 - 只有黑色窗口出现。

出了什么问题?

enter image description here

备注:x64窗口10版

2 个答案:

答案 0 :(得分:1)

你可以使用我最近使用的牵线木偶驱动程序。您需要下载并重命名为wires.exe。您可以从以下链接下载 https://github.com/mozilla/geckodriver/releases

您需要添加selenium-2.53.0 jar文件。

下面是您需要编写的代码。

System.setProperty("webdriver.gecko.driver", "G:\\ravik\\Ravi-Training\\Selenium\\Marionette for firefox\\wires.exe");
    WebDriver driver = new MarionetteDriver();
    driver.get("https://www.google.co.in/webhp?hl=en&sa=X&ved=0ahUKEwjdgc21jJHOAhVCvY8KHZ4aCdcQPAgD");
    System.out.println("marionette working fine....");

答案 1 :(得分:0)

对于所有仍感到困惑的人:

  

怎么了?

好吧,没什么错,您只需要了解 geckodriver.exe 是驱动程序本身,而不是最终会在您的计算机上安装该驱动程序的安装程序。

因此,要使用(或说安装)驱动程序,您需要执行两个步骤:

  1. 解压缩计算机上的文件夹(您已经做过),并且
  2. 添加驱动程序可执行路径以测试属性(Ravi指出了这一点)

附加说明:我使用Intellij IDEA运行测试,因此我只需编辑测试运行配置并添加以下行即可:
-Dwebdriver.gecko.driver="Path\to\my\geckodriver.exe"