2015-05-24 60 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