2017-04-11 193 views
-1

任何人都可以用這些錯誤的幫助或告訴我是什麼導致了他們,我添加了所有被我從下載的文件中的.JAR文件seleniumHQ.org但IM仍然得到這些錯誤:硒的webdriver(JAVA)

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:738) 

at org.openqa.selenium.remote.service.DriverService.findExecutable 
(DriverService.java:111) 

at org.openqa.selenium.firefox.GeckoDriverService.access$100 
(GeckoDriverService.java:38) 

at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable 
(GeckoDriverService.java:112) 

at org.openqa.selenium.remote.service.DriverService$Builder.build 
(DriverService.java:302) 

at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:233) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:121) 
    at seleniumTakeTwo.testTutorialTwo.main(testTutorialTwo.java:11) 
+0

你需要有一個硒驅動程序來使用。在您的錯誤中提到的那個是https://github.com/mozilla/geckodriver/releases –

+0

您是否讀過錯誤,請點擊鏈接,然後按照指示進行操作? – JeffC

回答

1

要與Mozila火狐52.0.2硒3.x的工作,你需要:

  1. 下載latest gecko driver並將其保存在 「C:\您的文件夾」。
  2. 設置系統屬性提其絕對路徑沿着你的系統上的壁虎司機:

System.setProperty("webdriver.gecko.driver", "C:\\your_folder\\geckodriver.exe");

  • 下一頁初始化的webdriver爲:
  • WebDriver driver = new FirefoxDriver();

  • 最大化的瀏覽器:
  • driver.manage().window().maximize();

  • 打開一個網址:
  • driver.get("http:\\gmail.com");

    讓我知道如果這能幫助你。