驱动程序可执行文件不存在:Selenium Firefox

时间:2016-11-23 22:24:13

标签: java selenium web driver gecko

过去几个小时我一直在努力解决这个问题。我正在尝试安装Selenium Web驱动程序,并且遇到了一堆错误,导致我无法运行测试页面。我很确定我最近的问题是这段代码:

 public static void main(String[] args) throws InterruptedException{
      System.setProperty("webdriver.gecko.driver","C:/Users/theone/Downloads/geckodriver 2.exe");

非常感谢第二步的任何反馈!

package automationFramework;

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

public class FirstTestCase {

    public static void main(String[] args) throws InterruptedException{
        System.setProperty("webdriver.gecko.driver","C:/Users/theone/Downloads/geckodriver 2.exe");

        // Create a new instance of the Firefox driver
        WebDriver driver = new FirefoxDriver();

        //Launch the Online Store Website
        driver.get("http://www.store.demoqa.com");

        // Print a Log In message to the screen
        System.out.println("Successfully opened the website www.Store.Demoqa.com");

        //Wait for 5 Sec
        Thread.sleep(5);

        // Close the driver
        driver.quit();
    }
}

2 个答案:

答案 0 :(得分:3)

您可以使用webdriver.gecko.driver属性或使用环境属性使用GeckoDriver设置Selenium。如果您使用最新版本的Firefox,GeckoDriver和Selenium 3.0

,那就太好了

查看这篇文章,它使用这两种方式提供设置 - http://automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/

答案 1 :(得分:3)

C:/Users/theone/Downloads/geckodriver 2.exe

路径中有空格,如果您重命名文件 geckodriver2.exe ,它可能会有效。