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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40775134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 05:27:38  来源:igfitidea点击:

The driver executable does not exist: Selenium Firefox

javaseleniumwebdrivergecko

提问by Rana Haram

I've been struggling with this for the past few hours. I'm trying to install Selenium web driver and have been running into a bunch of errors which prevent me from running the test page. I'm pretty sure my most recent issue is with this code:

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

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

Would really appreciate any feedback on second steps!

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

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();
    }
}

回答by Anish Pillai

You can setup Selenium with GeckoDriver either with webdriver.gecko.driver property or using environment properties. It would be good if you the latest version of Firefox, GeckoDriver and Selenium 3.0

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

Check out this article which provides setup using both these ways - http://automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/

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

回答by Y-B Cause

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

There's a space in the path, it may work if you rename your file geckodriver2.exe.

路径中有一个空格,如果您重命名文件geckodriver2.exe可能会起作用。