Java Selenium - org.openqa.selenium.WebDriverException: f.QueryInterface 不是一个函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22145776/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Selenium - org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
提问by Poorva
@Test
public void myDriver() throws IOException, InterruptedException {
FirefoxDriver myD = new FirefoxDriver();
String vkw, vxpath, vtestdata;
long iWait = 1000000000;
String[][] xTC, xTS;
xTC = readxl("C:\Selenium\KDF.xls", "Test case");
xTS = readxl("C:\Selenium\KDF.xls", "Test steps");
for (int i = 1; i < xTC.length; i++) {
if (xTC[i][3].equalsIgnoreCase("Y")) {
System.out.println("Yes");
for (int k = 1; k < xTS.length; k++) {
if (xTC[i][0].equalsIgnoreCase(xTS[k][1])) {
vkw = xTS[k][4];
vxpath = xTS[k][5];
vtestdata = xTS[k][5];
/* if (vkw.equalsIgnoreCase("enter text")){
Fentertext(myD, vxpath, vtestdata);
}
*/
if (vkw.equalsIgnoreCase("navigate browser")) {
FnavigateBrowser(myD, vtestdata);
}
Thread.sleep(iWait);
}
}
}
}
}
Error:- org.openqa.selenium.WebDriverException: f.QueryInterface is
not a function Command duration or timeout: 144 milliseconds Build
info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16
16:12:12' System info: host: 'del1-dhp-28988', ip: '172.16.45.14',
os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1',
java.version: '1.7.0_09' Session ID:
043a4dc7-520f-44a5-a74c-c6cb274d50b9 Driver info:
org.openqa.selenium.firefox.FirefoxDriver Capabilities [{platform=XP,
acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true,
databaseEnabled=true, browserName=firefox, handlesAlerts=true,
browserConnectionEnabled=true, webStorageEnabled=true,
nativeEvents=true, rotatable=false, locationContextEnabled=true,
applicationCacheEnabled=true, takesScreenshot=true, version=26.0}]
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:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:276)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteNavigation.to(RemoteWebDriver.java:800)
at KDF3.FnavigateBrowser(KDF3.java:185)
at KDF3.myDriver(KDF3.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access##代码##0(ParentRunner.java:42)
at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by:
org.openqa.selenium.remote.ErrorHandler$UnknownServerException:
f.QueryInterface is not a function Build info: version: '2.39.0',
revision: 'ff23eac', time: '2013-12-16 16:12:12' System info: host:
'del1-dhp-28988', ip: '172.16.45.14', os.name: 'Windows 7', os.arch:
'amd64', os.version: '6.1', java.version: '1.7.0_09' Driver info:
driver.version: unknown
at <anonymous class>.FirefoxDriver.prototype.get(file:///C:/Users/POORVA~1.SHA/AppData/Local/Temp/anonymous8563012586736156603webdriver-profile/extensions/[email protected]/components/driver_component.js:8720)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/POORVA~1.SHA/AppData/Local/Temp/anonymous8563012586736156603webdriver-profile/extensions/[email protected]/components/command_processor.js:10831)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/POORVA~1.SHA/AppData/Local/Temp/anonymous8563012586736156603webdriver-profile/extensions/[email protected]/components/command_processor.js:10836)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/POORVA~1.SHA/AppData/Local/Temp/anonymous8563012586736156603webdriver-profile/extensions/[email protected]/components/command_processor.js:10778)
回答by Erki M.
The error is being thrown by webdriver's get method that is navigating you to the url that you provided. Most probably your URL is missing a protocol. So a wild guess would be, that you are passing url as www.example.com
, but what you want to give is http://www.example.com
该错误是由 webdriver 的 get 方法引发的,该方法将您导航到您提供的 url。很可能您的 URL 缺少协议。因此,一个疯狂的猜测是,您将 url 传递为www.example.com
,但是您想要提供的是http://www.example.com
回答by mahesh mathpal
WebDriver api sends RESTfull request to Selenium server to execute a command. REST services uses http or https protocol for request/response. Hence when we call the url without mentioning the protocol prefix (in our case http), exception is thrown.
WebDriver api 向 Selenium 服务器发送 RESTfull 请求以执行命令。REST 服务使用 http 或 https 协议进行请求/响应。因此,当我们在不提及协议前缀(在我们的例子中为 http)的情况下调用 url 时,会抛出异常。
回答by kane morgan
I ran into this error in a ruby on rails web app when running feature tests with rspec/capybara.
使用 rspec/capybara 运行功能测试时,我在 ruby on rails web 应用程序中遇到了这个错误。
For me it was fixed by adding a "/" to the front of the url in the visit method.
对我来说,它是通过在访问方法中的 url 前面添加一个“/”来修复的。
so visit "your/test/path"
所以 visit "your/test/path"
becomes visit "/your/test/path"
变成 visit "/your/test/path"
回答by kane morgan
Another possibility is that you accidentally forgot/deleted the line require 'capybara/rails'
in your test helper file in a Ruby on Rails project. Took me an hour to realize. Damn typos!
另一种可能性是您不小心忘记/删除require 'capybara/rails'
了 Ruby on Rails 项目中测试帮助文件中的行。我花了一个小时才意识到。该死的错别字!
回答by Rreddy
If the URL is saved with quotes in config file, it throws the f.queryInterface
exception. Just remove the quotes for the URL and it will work fine.
如果 URL 在配置文件中用引号保存,则会引发f.queryInterface
异常。只需删除 URL 的引号,它就可以正常工作。
回答by user3817496
org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
exception happens because of the missing protocol. If you are using url without protocol like (http or https) then it throws above exception.
org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
由于缺少协议而发生异常。如果您使用的 url 没有像(http 或 https)这样的协议,那么它会抛出上述异常。