2016-11-07 37 views
1

我有Selenium版本3.0.1和Firefox版本46.0.1。 在硒3.0.1 changelog應提到的是:使用Selenium 3.0啓動Firefox 46.0.1時出現IllegalStateException

Geckodriver is now the default mechanism for automating Firefox. This is Mozilla's implementation of a driver for that browser, and is required for automating Firefox versions 48 and above

雖然我得到錯誤:

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

在執行下面的代碼

@Test 
public void test() { 
    WebDriver driver = new FirefoxDriver(); 
    driver.get("http://www.google.com"); 
    driver.quit(); 
} 

爲什麼我收到這個錯誤但我使用Firefox版本< 48.0? Selenium 3.0.1是否必須使用Geckodriver?你提到

System.setProperty("webdriver.gecko.driver","path to geckodriver"); 
WebDriver driver = new FirefoxDriver(); 

回答

0

更新日誌鏈接是DOTNET:

上面的代碼,如果我做以下修改工作完美。這裏是Changelog爲Java

  • Firefox is only fully supported at version 47.0.1 or earlier. Support for later versions of firefox is provided by geckodriver, which is based on the evolving W3C WebDriver spec, and uses the wire protocol in that spec, which is liable to change without notice.
  • You may wish to choose an ESR release such as 45.4.0esr or earlier.
  • Firefox 47.0.0 is not supported at all.
+0

它提到,對於firefox版本> 47.0.1需要geckodriver。 –

+0

只有47.0.1或更早的版本才支持Firefox,並且我使用的是46.0.1,雖然它提供了一個例外,即需要設置geckodriver –

1

必須selenium 3.0設置以下屬性爲所有Firefox瀏覽器無關的版本起:

System.setProperty("webdriver.gecko.driver","path to geckodriver"); 

Geckodriver is now the default mechanism for automating Firefox. This is Mozilla's implementation of a driver for that browser, and is required for automating Firefox versions 48 and above

設置路徑是強制性的。

如果您想在Firefox 47或之前運行測試,請將Firefox驅動程序功能「marionette」設置爲false。

DesiredCapabilities d = new DesiredCapabilities(); 
d.setCapability("marionette", false); // to disable marionette. 
WebDriver driver = new FirefoxDriver(d); 
相關問題