【问题标题】:What are the steps to set a path to a driver executable? [duplicate]设置驱动程序可执行文件路径的步骤是什么? [复制]
【发布时间】:2016-12-30 09:58:21
【问题描述】:

我是一个刚开始学习 Selenium 的新手,现在在 ubuntu 下使用 eclipse。 但是在运行我的第一个程序时

public class FirstTestCase {

    public static void main(String[] args) throws InterruptedException {
        // TODO Auto-generated method stub

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

        //Launch the Website
        driver.get("https://www.google.com");

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

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

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

我得到了这个错误,我不知道如何设置路径。我只是从 github 下载最新的 linux 版本的 geckodriver 并将其放在我的桌面上。谢谢你的帮助

Exception in thread "main" java.lang.IllegalStateException: The path
 to the driver executable must be set by the webdriver.gecko.driver
 system property; for more information, see
 https://github.com/mozilla/geckodriver. The latest version can be
 downloaded from https://github.com/mozilla/geckodriver/releases
        at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
        at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
        at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:38)
        at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:91)
        at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
        at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:245)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:220)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:215)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:124)
        at automationFramework.FirstTestCase.main(FirstTestCase.java:14)

【问题讨论】:

    标签: java eclipse selenium


    【解决方案1】:

    您可以在命令行参数中添加-D&lt;name&gt;=&lt;value&gt; 来设置系统属性。

    据我所知,您可以通过按run 按钮旁边的小三角形来配置此参数。

    【讨论】:

      猜你喜欢
      • 2019-02-08
      • 1970-01-01
      • 2023-03-24
      • 2016-04-29
      • 2020-11-27
      • 2020-03-14
      • 2017-09-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多