2015-05-24 53 views
2

我已經使用Firefox的早期版本2.44 - 它工作正常。硒單獨2.45.0;腳本崩潰Firefox 38.0.1

FirefoxDriver ffd = new FirefoxDriver(); 
ffd.get("www.google.com"); 

現在,連這個簡單的調用拋出一個異常:

Exception in thread "main" org.openqa.selenium.WebDriverException: f.QueryInterface is not a function 
Command duration or timeout: 190 milliseconds 
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50' 
System info: host: 'Shivam-PC', ip: '192.168.0.107', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_31' 
Driver info: org.openqa.selenium.firefox.FirefoxDriver 
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=38.0.1, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] 
Session ID: 19f3d00e-ad14-4fc8-9d29-cee47ae44186 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
    at java.lang.reflect.Constructor.newInstance(Unknown Source) 
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204) 
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599) 
    at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:304) 
    at sele.Sample.main(Sample.java:13) 
Caused by: org.openqa.selenium.WebDriverException: f.QueryInterface is not a function 
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50' 
System info: host: 'Shivam-PC', ip: '192.168.0.107', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_31' 
Driver info: driver.version: unknown 
    at <anonymous class>.FirefoxDriver.prototype.get(file:///C:/Users/Shivam/AppData/Local/Temp/anonymous4862788616202211612webdriver-profile/extensions/[email protected]/components/driver-component.js:10132) 
    at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/Shivam/AppData/Local/Temp/anonymous4862788616202211612webdriver-profile/extensions/[email protected]/components/command-processor.js:12274) 
    at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/Shivam/AppData/Local/Temp/anonymous4862788616202211612webdriver-profile/extensions/[email protected]/components/command-processor.js:12279) 
    at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/Shivam/AppData/Local/Temp/anonymous4862788616202211612webdriver-profile/extensions/[email protected]/components/command-processor.js:12221) 
+0

聽起來像是兼容性問題。將firefox降級到35.0.1。 – alecxe

+0

當Firefix升級到38.0.1時,同樣的問題。我降級到了早期的37,運行良好。 –

回答

1

它似乎是從版本到版本的常見問題(我遇到過FF v.36這類問題)。主要工作是不要將FF更新到最新版本(或者如果最壞的情況發生,則降級)。如果你的測試適用於特定的FF版本 - >至少要堅持到新版本的WebDriver發佈。

對我自己而言,最可靠的版本是FF v.33。

+0

如何降級ff? –

+0

首先檢查Selenium 2.46.0版本[注意](https://raw.githubusercontent.com/SeleniumHQ/selenium/master/java/CHANGELOG)。您可以從Mozilla [ftp](http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/33)下載FF33。0/win32的/ EN-US /) –

1

在我看來,處理Firefox上Selenium測試的最強大的解決方案是堅持使用CHANGELOG文件中提到的最新ESR(Extended Support Release)。 Selenium團隊必須跟上Firefox中引入的變化,這可能自然會導致最新版本的問題 - not much has changed since the Selenium RC days in this respect

更新2016年1月18日:現在ESR釋放此更新日誌中提到,有因爲使用Firefox 33,本機事件的支持已經有利於合成事件的下降。維基states

本地事件模擬用戶交互更好,而合成 事件是平臺獨立的,它可以當使用 替代窗口管理器在Linux中是很重要的,看到native events on Linux。 只要有可能,就應該使用本機事件。

所以根據您的操作系統,你可以嘗試兩個版本爲您找到一個更適合:

最後提到的是Selenium 2.47.0,包括Firefox版本31,38和39.

如果您想要使用最新的ESR版本,Mozilla也提供了link for that