Selenium2学习-007-WebUI自动化实战实例-005-解决 Firefox 版本不兼容:org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary
此文主要讲述 Java 运行 Selenium 脚本时,因 Friefox 浏览器版本与 selenium-server-standalone-x.xx.x.jar 不兼容引起的 org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary 报错解决方法。
希望能对初学 Selenium2 WebUI 自动化测试编程的亲们有所帮助。若有不足之处,敬请大神指正,不胜感激!
之前给朋友初步介绍了 Selenium 启动不同浏览器的脚本编写,对应源码亲们可参阅博文:WebUI自动化实战实例-003-三种浏览器(Chrome、Firefox、IE)启动脚本。今天,在朋友 PC 上运行时,提示如下的错误信息:
1 org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: 2 thod startup on [email protected] version 0.9 3 1421571095765 addons.xpi DEBUG Registering manifest for C:\Users\机器名\AppData\Local\Temp\anonymous2976645405089665816webdriver-profile\extensions\wx-[email protected] 4 1421571095765 addons.xpi DEBUG Loading bootstrap scope from C:\Users\机器名\AppData\Local\Temp\anonymous2976645405089665816webdriver-profile\extensions\wx-[email protected] 5 1421571095767 addons.xpi DEBUG Calling bootstrap method startup on [email protected] version 1.1.2 6 1421571095785 addons.manager DEBUG Registering shutdown blocker for XPIProvider 7 1421571095785 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager 8 1421571095786 addons.manager DEBUG Registering shutdown blocker for OpenH264Provider 9 1421571095786 addons.manager DEBUG Registering shutdown blocker for PluginProvider 10 JavaScript error: file:///C:/Users/机器名/AppData/Local/Temp/anonymous2976645405089665816webdriver-profile/extensions/[email protected]/components/mozCNGuard.js, line 287: TypeError: w.gBrowser is undefined 11 JavaScript warning: resource://addoninstaller/log4moz.js, line 494: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create 12 1421571096533 addons.manager DEBUG Registering shutdown blocker for <unnamed-provider> 13 1421571096773 addons.xpi-utils DEBUG Starting async load of XPI database C:\Users\机器名\AppData\Local\Temp\anonymous2976645405089665816webdriver-profile\extensions.json 14 *** Blocklist::_loadBlocklistFromFile: blocklist is disabled 15 1421571097073 addons.xpi-utils DEBUG Async JSON file read took 0 MS 16 1421571097073 addons.xpi-utils DEBUG Finished async read of XPI database, parsing... 17 1421571097074 addons.xpi-utils DEBUG Successfully read XPI database 18 console.error: commonfix: 19 Message: TypeError: redeclaration of variable settings 20 Stack: 21 @resource://commonfix-at-mozillaonline-dot-com/commonfix/lib/main.js:231:undefined 22 CuddlefishLoader/options<.load@resource://gre/modules/commonjs/sdk/loader/cuddlefish.js:129:18 23 run@resource://gre/modules/commonjs/sdk/addon/runner.js:145:19 24 startup/</<@resource://gre/modules/commonjs/sdk/addon/runner.js:86:7 25 Handler.prototype.process@resource://gre/modules/Promise-backend.js:865:23 26 this.PromiseWalker.walkerLoop@resource://gre/modules/Promise-backend.js:744:7 27 28 ************************* 29 A coding exception was thrown in a Promise resolution callback. 30 See https://developer.mozilla.org/Mozilla/JavaScript_code_modules/Promise.jsm/Promise 31 32 Full message: TypeError: redeclaration of variable settings 33 Full stack: @resource://commonfix-at-mozillaonline-dot-com/commonfix/lib/main.js:231:undefined 34 CuddlefishLoader/options<.load@resource://gre/modules/commonjs/sdk/loader/cuddlefish.js:129:18 35 run@resource://gre/modules/commonjs/sdk/addon/runner.js:145:19 36 startup/</<@resource://gre/modules/commonjs/sdk/addon/runner.js:86:7 37 Handler.prototype.process@resource://gre/modules/Promise-backend.js:865:23 38 this.PromiseWalker.walkerLoop@resource://gre/modules/Promise-backend.js:744:7 39 40 ************************* 41 console.error: commonfix: 42 Message: TypeError: redeclaration of variable settings 43 Stack: 44 @resource://commonfix-at-mozillaonline-dot-com/commonfix/lib/main.js:231:undefined 45 CuddlefishLoader/options<.load@resource://gre/modules/commonjs/sdk/loader/cuddlefish.js:129:18 46 run@resource://gre/modules/commonjs/sdk/addon/runner.js:145:19 47 startup/</<@resource://gre/modules/commonjs/sdk/addon/runner.js:86:7 48 Handler.prototype.process@resource://gre/modules/Promise-backend.js:865:23 49 this.PromiseWalker.walkerLoop@resource://gre/modules/Promise-backend.js:744:7 50 51 1421571097193 addons.repository DEBUG No addons.json found. 52 1421571097194 DeferredSave.addons.json DEBUG Save changes 53 1421571097195 DeferredSave.addons.json DEBUG Starting timer 54 1421571097250 DeferredSave.addons.json DEBUG Starting write 55 1421571097253 DeferredSave.addons.json DEBUG Write succeeded 56 57 at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118) 58 at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246) 59 at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114) 60 at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193) 61 at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186) 62 at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182) 63 at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95) 64 at main.java.aaron.sele.demo.StartBrowerFirefox.FirefoxStart(StartBrowerFirefox.java:39) 65 at main.java.aaron.sele.demo.StartBrowerFirefox.main(StartBrowerFirefox.java:54) 66 Exception in thread "main" org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7055; process output follows: 67 thod startup on [email protected] version 0.9 68 1421571095765 addons.xpi DEBUG Registering manifest for C:\Users\机器名\AppData\Local\Temp\anonymous2976645405089665816webdriver-profile\extensions\wx-[email protected] 69 1421571095765 addons.xpi DEBUG Loading bootstrap scope from C:\Users\机器名\AppData\Local\Temp\anonymous2976645405089665816webdriver-profile\extensions\wx-[email protected] 70 1421571095767 addons.xpi DEBUG Calling bootstrap method startup on [email protected] version 1.1.2 71 1421571095785 addons.manager DEBUG Registering shutdown blocker for XPIProvider 72 1421571095785 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager 73 1421571095786 addons.manager DEBUG Registering shutdown blocker for OpenH264Provider 74 1421571095786 addons.manager DEBUG Registering shutdown blocker for PluginProvider 75 JavaScript error: file:///C:/Users/机器名/AppData/Local/Temp/anonymous2976645405089665816webdriver-profile/extensions/[email protected]/components/mozCNGuard.js, line 287: TypeError: w.gBrowser is undefined 76 JavaScript warning: resource://addoninstaller/log4moz.js, line 494: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create 77 1421571096533 addons.manager DEBUG Registering shutdown blocker for <unnamed-provider> 78 1421571096773 addons.xpi-utils DEBUG Starting async load of XPI database C:\Users\机器名\AppData\Local\Temp\anonymous2976645405089665816webdriver-profile\extensions.json 79 *** Blocklist::_loadBlocklistFromFile: blocklist is disabled 80 1421571097073 addons.xpi-utils DEBUG Async JSON file read took 0 MS 81 1421571097073 addons.xpi-utils DEBUG Finished async read of XPI database, parsing... 82 1421571097074 addons.xpi-utils DEBUG Successfully read XPI database 83 console.error: commonfix: 84 Message: TypeError: redeclaration of variable settings 85 Stack: 86 @resource://commonfix-at-mozillaonline-dot-com/commonfix/lib/main.js:231:undefined 87 CuddlefishLoader/options<.load@resource://gre/modules/commonjs/sdk/loader/cuddlefish.js:129:18 88 run@resource://gre/modules/commonjs/sdk/addon/runner.js:145:19 89 startup/</<@resource://gre/modules/commonjs/sdk/addon/runner.js:86:7 90 Handler.prototype.process@resource://gre/modules/Promise-backend.js:865:23 91 this.PromiseWalker.walkerLoop@resource://gre/modules/Promise-backend.js:744:7 92 93 ************************* 94 A coding exception was thrown in a Promise resolution callback. 95 See https://developer.mozilla.org/Mozilla/JavaScript_code_modules/Promise.jsm/Promise 96 97 Full message: TypeError: redeclaration of variable settings 98 Full stack: @resource://commonfix-at-mozillaonline-dot-com/commonfix/lib/main.js:231:undefined 99 CuddlefishLoader/options<.load@resource://gre/modules/commonjs/sdk/loader/cuddlefish.js:129:18 100 run@resource://gre/modules/commonjs/sdk/addon/runner.js:145:19 101 startup/</<@resource://gre/modules/commonjs/sdk/addon/runner.js:86:7 102 Handler.prototype.process@resource://gre/modules/Promise-backend.js:865:23 103 this.PromiseWalker.walkerLoop@resource://gre/modules/Promise-backend.js:744:7 104 105 ************************* 106 console.error: commonfix: 107 Message: TypeError: redeclaration of variable settings 108 Stack: 109 @resource://commonfix-at-mozillaonline-dot-com/commonfix/lib/main.js:231:undefined 110 CuddlefishLoader/options<.load@resource://gre/modules/commonjs/sdk/loader/cuddlefish.js:129:18 111 run@resource://gre/modules/commonjs/sdk/addon/runner.js:145:19 112 startup/</<@resource://gre/modules/commonjs/sdk/addon/runner.js:86:7 113 Handler.prototype.process@resource://gre/modules/Promise-backend.js:865:23 114 this.PromiseWalker.walkerLoop@resource://gre/modules/Promise-backend.js:744:7 115 116 1421571097193 addons.repository DEBUG No addons.json found. 117 1421571097194 DeferredSave.addons.json DEBUG Save changes 118 1421571097195 DeferredSave.addons.json DEBUG Starting timer 119 1421571097250 DeferredSave.addons.json DEBUG Starting write 120 1421571097253 DeferredSave.addons.json DEBUG Write succeeded 121 122 Build info: version: ‘2.42.2‘, revision: ‘6a6995d‘, time: ‘2014-06-03 17:42:03‘ 123 System info: host: ‘机器名-PC‘, ip: ‘10.24.68.138‘, os.name: ‘Windows 7‘, os.arch: ‘amd64‘, os.version: ‘6.1‘, java.version: ‘1.8.0‘ 124 Driver info: driver.version: FirefoxDriver 125 at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:130) 126 at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246) 127 at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114) 128 at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193) 129 at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186) 130 at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182) 131 at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95) 132 at main.java.aaron.sele.demo.StartBrowerFirefox.FirefoxStart(StartBrowerFirefox.java:39) 133 at main.java.aaron.sele.demo.StartBrowerFirefox.main(StartBrowerFirefox.java:54) 134 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: 135 thod startup on [email protected] version 0.9 136 1421571095765 addons.xpi DEBUG Registering manifest for C:\Users\机器名\AppData\Local\Temp\anonymous2976645405089665816webdriver-profile\extensions\wx-[email protected] 137 1421571095765 addons.xpi DEBUG Loading bootstrap scope from C:\Users\机器名\AppData\Local\Temp\anonymous2976645405089665816webdriver-profile\extensions\wx-[email protected] 138 1421571095767 addons.xpi DEBUG Calling bootstrap method startup on [email protected] version 1.1.2 139 1421571095785 addons.manager DEBUG Registering shutdown blocker for XPIProvider 140 1421571095785 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager 141 1421571095786 addons.manager DEBUG Registering shutdown blocker for OpenH264Provider 142 1421571095786 addons.manager DEBUG Registering shutdown blocker for PluginProvider 143 JavaScript error: file:///C:/Users/机器名/AppData/Local/Temp/anonymous2976645405089665816webdriver-profile/extensions/[email protected]/components/mozCNGuard.js, line 287: TypeError: w.gBrowser is undefined 144 JavaScript warning: resource://addoninstaller/log4moz.js, line 494: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create 145 1421571096533 addons.manager DEBUG Registering shutdown blocker for <unnamed-provider> 146 1421571096773 addons.xpi-utils DEBUG Starting async load of XPI database C:\Users\机器名\AppData\Local\Temp\anonymous2976645405089665816webdriver-profile\extensions.json 147 *** Blocklist::_loadBlocklistFromFile: blocklist is disabled 148 1421571097073 addons.xpi-utils DEBUG Async JSON file read took 0 MS 149 1421571097073 addons.xpi-utils DEBUG Finished async read of XPI database, parsing... 150 1421571097074 addons.xpi-utils DEBUG Successfully read XPI database 151 console.error: commonfix: 152 Message: TypeError: redeclaration of variable settings 153 Stack: 154 @resource://commonfix-at-mozillaonline-dot-com/commonfix/lib/main.js:231:undefined 155 CuddlefishLoader/options<.load@resource://gre/modules/commonjs/sdk/loader/cuddlefish.js:129:18 156 run@resource://gre/modules/commonjs/sdk/addon/runner.js:145:19 157 startup/</<@resource://gre/modules/commonjs/sdk/addon/runner.js:86:7 158 Handler.prototype.process@resource://gre/modules/Promise-backend.js:865:23 159 this.PromiseWalker.walkerLoop@resource://gre/modules/Promise-backend.js:744:7 160 161 ************************* 162 A coding exception was thrown in a Promise resolution callback. 163 See https://developer.mozilla.org/Mozilla/JavaScript_code_modules/Promise.jsm/Promise 164 165 Full message: TypeError: redeclaration of variable settings 166 Full stack: @resource://commonfix-at-mozillaonline-dot-com/commonfix/lib/main.js:231:undefined 167 CuddlefishLoader/options<.load@resource://gre/modules/commonjs/sdk/loader/cuddlefish.js:129:18 168 run@resource://gre/modules/commonjs/sdk/addon/runner.js:145:19 169 startup/</<@resource://gre/modules/commonjs/sdk/addon/runner.js:86:7 170 Handler.prototype.process@resource://gre/modules/Promise-backend.js:865:23 171 this.PromiseWalker.walkerLoop@resource://gre/modules/Promise-backend.js:744:7 172 173 ************************* 174 console.error: commonfix: 175 Message: TypeError: redeclaration of variable settings 176 Stack: 177 @resource://commonfix-at-mozillaonline-dot-com/commonfix/lib/main.js:231:undefined 178 CuddlefishLoader/options<.load@resource://gre/modules/commonjs/sdk/loader/cuddlefish.js:129:18 179 run@resource://gre/modules/commonjs/sdk/addon/runner.js:145:19 180 startup/</<@resource://gre/modules/commonjs/sdk/addon/runner.js:86:7 181 Handler.prototype.process@resource://gre/modules/Promise-backend.js:865:23 182 this.PromiseWalker.walkerLoop@resource://gre/modules/Promise-backend.js:744:7 183 184 1421571097193 addons.repository DEBUG No addons.json found. 185 1421571097194 DeferredSave.addons.json DEBUG Save changes 186 1421571097195 DeferredSave.addons.json DEBUG Starting timer 187 1421571097250 DeferredSave.addons.json DEBUG Starting write 188 1421571097253 DeferredSave.addons.json DEBUG Write succeeded 189 190 at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118) 191 ... 8 more
从信息中可看出,Selenium 无法启动 Friefox 浏览器而导致程序报错信息。解决步骤:
- 初始以为是因为 WebDriver 驱动的问题,更换后发现问题依然存在
- 查看其 Firefox 的版本为 35,觉得问题出在了 Firefox 版本与 selenium-server-standalone 版本不对应导致的,于是将 Firefox 版本降至 31,脚本运行通过;
- 将 Firefox 版本升级为 35,下载最新的 selenium-server-standalone-2.44.0.jar(下载地址:http://yunpan.cn/cyaZTHGtiav9Y 提取码 96a6) 导入工程,脚本运行通过
至此,WebUI 自动化功能测试脚本第 004 篇-解决 Firefox 版本不兼容:org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary 顺利完结,希望此文能够给初学 Selenium 的您一份参考。
最后,非常感谢亲的驻足,希望此文能对亲有所帮助。热烈欢迎亲一起探讨,共同进步。非常感谢! ^_^
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。