尝试通过java运行一个非常简单的selenium脚本时出现此错误。尝试创建新的FireFoxWebDriver()
我看到过类似的错误,但它们已经很老了,似乎没有一个好的解决方案。我使用selenium-java和selenium-firefox-driver两个版本2.51.0。我的firefox版本是43.0.2,selenium网站说他们支持最新版本的firefox,所以我认为这不是问题。
非常感谢任何帮助,谢谢!
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
1455135105046 addons.xpi INFO Mapping fxdriver@googlecode.com to /var/folders/hn/5gwsh3wj3v198z7w59srnrh00000gn/T/anonymous724724030317929263webdriver-profile/extensions/fxdriver@googlecode.com
1455135105047 addons.xpi DEBUG Ignoring file entry whose name is not a valid add-on ID: /var/folders/hn/5gwsh3wj3v198z7w59srnrh00000gn/T/anonymous724724030317929263webdriver-profile/extensions/webdriver-staging
1455135105047 addons.xpi INFO SystemAddonInstallLocation directory is missing
1455135105047 addons.xpi INFO Mapping {972ce4c6-7e08-4474-a285-3208198ce6fd} to /Applications/Firefox.app/Contents/Resources/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}
1455135105047 addons.xpi DEBUG Skipping unavailable install location app-system-share
1455135105048 addons.xpi DEBUG checkForChanges
1455135105048 addons.xpi DEBUG Loaded add-on state from prefs: {"app-profile":{"fxdriver@googlecode.com":{"d":"/var/folders/hn/5gwsh3wj3v198z7w59srnrh00000gn/T/anonymous724724030317929263webdriver-profile/extensions/fxdriver@googlecode.com","e":false,"v":"2.40.0","st":1455135098000,"mt":1455135098000}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"/Applications/Firefox.app/Contents/Resources/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}","e":true,"v":"43.0.2","st":1451941111000,"mt":1451941105000}}}
1455135105049 addons.xpi DEBUG Existing add-on fxdriver@googlecode.com in app-profile
1455135105049 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1455135105049 addons.xpi DEBUG Existing add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} in app-global
1455135105049 addons.xpi DEBUG getInstallState changed: false, state: {"app-profile":{"fxdriver@googlecode.com":{"d":"/var/folders/hn/5gwsh3wj3v198z7w59srnrh00000gn/T/anonymous724724030317929263webdriver-profile/extensions/fxdriver@googlecode.com","e":false,"v":"2.40.0","st":1455135098000,"mt":1455135098000}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"/Applications/Firefox.app/Contents/Resources/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}","e":true,"v":"43.0.2","st":1451941111000,"mt":1451941105000}}}
1455135105050 addons.xpi DEBUG No changes found
1455135105056 addons.manager DEBUG Registering shutdown blocker for XPIProvider
1455135105056 addons.manager DEBUG Provider finished startup: XPIProvider
1455135105057 addons.manager DEBUG Starting provider: LightweightThemeManager
1455135105057 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager
1455135105057 addons.manager DEBUG Provider finished startup: LightweightThemeManager
1455135105058 addons.manager DEBUG Starting provider: GMPProvider
1455135105061 addons.manager DEBUG Registering shutdown blocker for GMPProvider
1455135105061 addons.manager DEBUG Provider finished startup: GMPProvider
1455135105061 addons.manager DEBUG Starting provider: PluginProvider
1455135105062 addons.manager DEBUG Registering shutdown blocker for PluginProvider
1455135105062 addons.manager DEBUG Provider finished startup: PluginProvider
1455135105062 addons.manager DEBUG Completed startup sequence
1455135105092 addons.xpi-utils DEBUG Starting async load of XPI database /var/folders/hn/5gwsh3wj3v198z7w59srnrh00000gn/T/anonymous724724030317929263webdriver-profile/extensions.json
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
1455135105216 addons.manager DEBUG Starting provider: <unnamed-provider>
1455135105216 addons.manager DEBUG Registering shutdown blocker for <unnamed-provider>
1455135105216 addons.manager DEBUG Provider finished startup: <unnamed-provider>
1455135105625 addons.xpi-utils DEBUG Async JSON file read took 0 MS
1455135105625 addons.xpi-utils DEBUG Finished async read of XPI database, parsing...
1455135105626 addons.xpi-utils DEBUG Successfully read XPI database
1455135105684 addons.manager DEBUG Starting provider: PreviousExperimentProvider
1455135105684 addons.manager DEBUG Registering shutdown blocker for PreviousExperimentProvider
1455135105685 addons.manager DEBUG Provider finished startup: PreviousExperimentProvider
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:112)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:192)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:187)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:183)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:96)
at selenium.AppDriverImpl.<init>(AppDriverImpl.java:35)
at selenium.SeleniumTestIT.test(SeleniumTestIT.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/Applications/Firefox.app/Contents/MacOS/firefox-bin) on port 7055; process output follows:
1455135105046 addons.xpi INFO Mapping fxdriver@googlecode.com to /var/folders/hn/5gwsh3wj3v198z7w59srnrh00000gn/T/anonymous724724030317929263webdriver-profile/extensions/fxdriver@googlecode.com
1455135105047 addons.xpi DEBUG Ignoring file entry whose name is not a valid add-on ID: /var/folders/hn/5gwsh3wj3v198z7w59srnrh00000gn/T/anonymous724724030317929263webdriver-profile/extensions/webdriver-staging
1455135105047 addons.xpi INFO SystemAddonInstallLocation directory is missing
1455135105047 addons.xpi INFO Mapping {972ce4c6-7e08-4474-a285-3208198ce6fd} to /Applications/Firefox.app/Contents/Resources/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}
1455135105047 addons.xpi DEBUG Skipping unavailable install location app-system-share
1455135105048 addons.xpi DEBUG checkForChanges
1455135105048 addons.xpi DEBUG Loaded add-on state from prefs: {"app-profile":{"fxdriver@googlecode.com":{"d":"/var/folders/hn/5gwsh3wj3v198z7w59srnrh00000gn/T/anonymous724724030317929263webdriver-profile/extensions/fxdriver@googlecode.com","e":false,"v":"2.40.0","st":1455135098000,"mt":1455135098000}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"/Applications/Firefox.app/Contents/Resources/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}","e":true,"v":"43.0.2","st":1451941111000,"mt":1451941105000}}}
1455135105049 addons.xpi DEBUG Existing add-on fxdriver@googlecode.com in app-profile
1455135105049 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1455135105049 addons.xpi DEBUG Existing add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} in app-global
1455135105049 addons.xpi DEBUG getInstallState changed: false, state: {"app-profile":{"fxdriver@googlecode.com":{"d":"/var/folders/hn/5gwsh3wj3v198z7w59srnrh00000gn/T/anonymous724724030317929263webdriver-profile/extensions/fxdriver@googlecode.com","e":false,"v":"2.40.0","st":1455135098000,"mt":1455135098000}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"/Applications/Firefox.app/Contents/Resources/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}","e":true,"v":"43.0.2","st":1451941111000,"mt":1451941105000}}}
1455135105050 addons.xpi DEBUG No changes found
1455135105056 addons.manager DEBUG Registering shutdown blocker for XPIProvider
1455135105056 addons.manager DEBUG Provider finished startup: XPIProvider
1455135105057 addons.manager DEBUG Starting provider: LightweightThemeManager
1455135105057 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager
1455135105057 addons.manager DEBUG Provider finished startup: LightweightThemeManager
1455135105058 addons.manager DEBUG Starting provider: GMPProvider
1455135105061 addons.manager DEBUG Registering shutdown blocker for GMPProvider
1455135105061 addons.manager DEBUG Provider finished startup: GMPProvider
1455135105061 addons.manager DEBUG Starting provider: PluginProvider
1455135105062 addons.manager DEBUG Registering shutdown blocker for PluginProvider
1455135105062 addons.manager DEBUG Provider finished startup: PluginProvider
1455135105062 addons.manager DEBUG Completed startup sequence
1455135105092 addons.xpi-utils DEBUG Starting async load of XPI database /var/folders/hn/5gwsh3wj3v198z7w59srnrh00000gn/T/anonymous724724030317929263webdriver-profile/extensions.json
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
1455135105216 addons.manager DEBUG Starting provider: <unnamed-provider>
1455135105216 addons.manager DEBUG Registering shutdown blocker for <unnamed-provider>
1455135105216 addons.manager DEBUG Provider finished startup: <unnamed-provider>
1455135105625 addons.xpi-utils DEBUG Async JSON file read took 0 MS
1455135105625 addons.xpi-utils DEBUG Finished async read of XPI database, parsing...
1455135105626 addons.xpi-utils DEBUG Successfully read XPI database
1455135105684 addons.manager DEBUG Starting provider: PreviousExperimentProvider
1455135105684 addons.manager DEBUG Registering shutdown blocker for PreviousExperimentProvider
1455135105685 addons.manager DEBUG Provider finished startup: PreviousExperimentProvider
Build info: version: '2.42.2', revision: '6a6995d31c7c56c340d6f45a76976d43506cd6cc', time: '2014-06-03 10:52:47'
System info: host: 'Caseys-MBP-2', ip: '192.168.1.75', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.3', java.version: '1.8.0_45'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:130)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:112)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:192)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:187)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:183)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:96)
at selenium.AppDriverImpl.<init>(AppDriverImpl.java:35)
at selenium.SeleniumTestIT.test(SeleniumTestIT.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
1455135105046 addons.xpi INFO Mapping fxdriver@googlecode.com to /var/folders/hn/5gwsh3wj3v198z7w59srnrh00000gn/T/anonymous724724030317929263webdriver-profile/extensions/fxdriver@googlecode.com
1455135105047 addons.xpi DEBUG Ignoring file entry whose name is not a valid add-on ID: /var/folders/hn/5gwsh3wj3v198z7w59srnrh00000gn/T/anonymous724724030317929263webdriver-profile/extensions/webdriver-staging
1455135105047 addons.xpi INFO SystemAddonInstallLocation directory is missing
1455135105047 addons.xpi INFO Mapping {972ce4c6-7e08-4474-a285-3208198ce6fd} to /Applications/Firefox.app/Contents/Resources/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}
1455135105047 addons.xpi DEBUG Skipping unavailable install location app-system-share
1455135105048 addons.xpi DEBUG checkForChanges
1455135105048 addons.xpi DEBUG Loaded add-on state from prefs: {"app-profile":{"fxdriver@googlecode.com":{"d":"/var/folders/hn/5gwsh3wj3v198z7w59srnrh00000gn/T/anonymous724724030317929263webdriver-profile/extensions/fxdriver@googlecode.com","e":false,"v":"2.40.0","st":1455135098000,"mt":1455135098000}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"/Applications/Firefox.app/Contents/Resources/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}","e":true,"v":"43.0.2","st":1451941111000,"mt":1451941105000}}}
1455135105049 addons.xpi DEBUG Existing add-on fxdriver@googlecode.com in app-profile
1455135105049 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1455135105049 addons.xpi DEBUG Existing add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} in app-global
1455135105049 addons.xpi DEBUG getInstallState changed: false, state: {"app-profile":{"fxdriver@googlecode.com":{"d":"/var/folders/hn/5gwsh3wj3v198z7w59srnrh00000gn/T/anonymous724724030317929263webdriver-profile/extensions/fxdriver@googlecode.com","e":false,"v":"2.40.0","st":1455135098000,"mt":1455135098000}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"/Applications/Firefox.app/Contents/Resources/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}","e":true,"v":"43.0.2","st":1451941111000,"mt":1451941105000}}}
1455135105050 addons.xpi DEBUG No changes found
1455135105056 addons.manager DEBUG Registering shutdown blocker for XPIProvider
1455135105056 addons.manager DEBUG Provider finished startup: XPIProvider
1455135105057 addons.manager DEBUG Starting provider: LightweightThemeManager
1455135105057 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager
1455135105057 addons.manager DEBUG Provider finished startup: LightweightThemeManager
1455135105058 addons.manager DEBUG Starting provider: GMPProvider
1455135105061 addons.manager DEBUG Registering shutdown blocker for GMPProvider
1455135105061 addons.manager DEBUG Provider finished startup: GMPProvider
1455135105061 addons.manager DEBUG Starting provider: PluginProvider
1455135105062 addons.manager DEBUG Registering shutdown blocker for PluginProvider
1455135105062 addons.manager DEBUG Provider finished startup: PluginProvider
1455135105062 addons.manager DEBUG Completed startup sequence
1455135105092 addons.xpi-utils DEBUG Starting async load of XPI database /var/folders/hn/5gwsh3wj3v198z7w59srnrh00000gn/T/anonymous724724030317929263webdriver-profile/extensions.json
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
1455135105216 addons.manager DEBUG Starting provider: <unnamed-provider>
1455135105216 addons.manager DEBUG Registering shutdown blocker for <unnamed-provider>
1455135105216 addons.manager DEBUG Provider finished startup: <unnamed-provider>
1455135105625 addons.xpi-utils DEBUG Async JSON file read took 0 MS
1455135105625 addons.xpi-utils DEBUG Finished async read of XPI database, parsing...
1455135105626 addons.xpi-utils DEBUG Successfully read XPI database
1455135105684 addons.manager DEBUG Starting provider: PreviousExperimentProvider
1455135105684 addons.manager DEBUG Registering shutdown blocker for PreviousExperimentProvider
1455135105685 addons.manager DEBUG Provider finished startup: PreviousExperimentProvider
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118)
... 30 more
答案 0 :(得分:2)
检查您的传递依赖并确保您确实使用了您认为自己的Selenium版本(2.51.0)
回顾FirefoxDriver
的历史记录,它对connection.start()
的号召已经很长时间没有上线(如2014年)。它目前在271年。
由于另一个WebDriver组件覆盖了您的首选版本,我怀疑您在2.40.0左右。在这种情况下,您可能会遇到其他人过去遇到的相同问题。
更新:事实上,如果你读了2/3的话就会有确认:
Build info: version: '2.42.2', revision: '6a6995d31c7c56c340d6f45a76976d43506cd6cc'
consensus似乎问题是版本不兼容,因此您应该升级到最近的WebDriver版本。
答案 1 :(得分:0)
如果您使用的是selenium版本3:
System.setProperty("webdriver.gecko.driver","C:\\Users\\vipin\\Downloads\\Compressed\\geckodriver.exe");
如果上述属性无效或在浏览器中打开应用程序,请尝试以下操作:
System.setProperty("webdriver.firefox.marionette","C:\\Users\\vipin\\Downloads\\Compressed\\geckodriver.exe");