我在开始编码时遇到异常

时间:2017-08-16 19:38:25

标签: selenium-webdriver

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:750)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124)
    at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:41)
    at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:115)
    at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:329)
    at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:207)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:103)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:99)
    at test_cases.Login_procedure.main(Login_procedure.java:10)

1 个答案:

答案 0 :(得分:0)

请按照以下步骤操作:

  1. 从GitHub下载gecko驱动程序。
  2. 将采用zip文件的形式。
  3. 根据您的方便提取文件并放置。
  4. 现在在代码中使用setProperty(String key,String path)方法来设置浏览器。