Exception in thread "main" org.openqa.selenium.WebDriverException

上一篇 / 下一篇  2015-09-14 13:47:20 / 个人分类:Selenium

Firefox启动后,却没有输入预设好的地址。
控制台也报错了。 
Error message:

Exception in thread "main" org.openqa.selenium.WebDriverException: f.QueryInterface is not a function

Command duration or timeout: 12 milliseconds

Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:17:10'

System info: host: 'ADMINIB-0RGD7I8', ip: '9.111.44.66', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_20'

Driver info: org.openqa.selenium.firefox.FirefoxDriver

Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=38.2.0, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]

Session ID: b398922c-08d6-45bc-a468-7b2ac4819936

     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

     at java.lang.reflect.Constructor.newInstance(Constructor.java:408)

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

     at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:306)

     at webdriver.OpenFirefox.main(OpenFirefox.java:16)

Caused by:org.openqa.selenium.WebDriverException: f.QueryInterface is not a function

Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:17:10'

System info: host: 'ADMINIB-0RGD7I8', ip: '9.111.44.66', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_20'

Driver info: driver.version: unknown

     at <anonymous class>.FirefoxDriver.prototype.get(file:///C:/Users/IBM_AD~1/AppData/Local/Temp/anonymous4308289603135526200webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10160)

     at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/IBM_AD~1/AppData/Local/Temp/anonymous4308289603135526200webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12282)

     at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/IBM_AD~1/AppData/Local/Temp/anonymous4308289603135526200webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12287)

     at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/IBM_AD~1/AppData/Local/Temp/anonymous4308289603135526200webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12229)


My Script. is as below: 

packagewebdriver;

 

importorg.openqa.selenium.WebDriver;

importorg.openqa.selenium.firefox.FirefoxDriver;

importorg.openqa.selenium.firefox.FirefoxProfile;

importorg.openqa.selenium.firefox.internal.ProfilesIni;

 

publicclassOpenFirefox {

 

    publicstaticvoidmain(String[] args) {

         System.out.println("Starting Firefox");

         ProfilesIni allProfiles=newProfilesIni();

         FirefoxProfile profile= allProfiles.getProfile("default");

         WebDriver driver =newFirefoxDriver(profile);

         System.out.println("Default Firefox.");

         driver.get("www.baidu.com");

         System.out.println("Done.");

     }

 

}


Solution:

The error is being thrown by webdriver's get method that is navigating you to the url that you provided. Most probably URL is missing a protocol. So a wild guess would be, that you are passing url as www.baidu.com, but what you want to give is http://www.baidu.com

driver.get("http://www.baidu.com");

 



TAG: thread Thread

 

评分:0

我来说两句

Open Toolbar