selenium2+WebDriver+Firefox浏览器报错

幽影梦魇 2014-10-09 05:03:30
package Test;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriver.Navigation;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class webTest {

public static void main(String[] args) {
DesiredCapabilities des = DesiredCapabilities.firefox();
des.setCapability("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
WebDriver driver = new FirefoxDriver(des);
Navigation navigation=driver.navigate();
navigation.to("http://www.baidu.com");

}

}


一直打开不了火狐浏览器,


报错信息如下:

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:
le
1412844901399 DeferredSave.extensions.json DEBUG Save changes
1412844901399 DeferredSave.extensions.json DEBUG Save changes
1412844901399 addons.xpi DEBUG Loading bootstrap scope from C:\Users\CAIYON~1\AppData\Local\Temp\anonymous7467163378569626774webdriver-profile\extensions\semodifier@mozillaonline.com.xpi
1412844901402 addons.xpi DEBUG Calling bootstrap method install on semodifier@mozillaonline.com version 0.2
1412844901451 addons.xpi DEBUG New add-on tabimprovelite@mozillaonline.com installed in app-profile
1412844901451 addons.xpi-utils DEBUG Make addon app-profile:tabimprovelite@mozillaonline.com visible
1412844901451 DeferredSave.extensions.json DEBUG Save changes
1412844901451 DeferredSave.extensions.json DEBUG Save changes
1412844901451 addons.xpi DEBUG New add-on wx-assistant@mozillaonline.com installed in app-profile
1412844901451 addons.xpi-utils DEBUG Make addon app-profile:wx-assistant@mozillaonline.com visible
1412844901451 DeferredSave.extensions.json DEBUG Save changes
1412844901451 DeferredSave.extensions.json DEBUG Save changes
1412844901452 addons.xpi DEBUG Loading bootstrap scope from C:\Users\CAIYON~1\AppData\Local\Temp\anonymous7467163378569626774webdriver-profile\extensions\wx-assistant@mozillaonline.com.xpi
1412844901454 addons.xpi DEBUG Calling bootstrap method install on wx-assistant@mozillaonline.com version 1.1.1
1412844901455 addons.xpi DEBUG New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
1412844901457 addons.xpi-utils DEBUG Make addon app-global:{972ce4c6-7e08-4474-a285-3208198ce6fd} visible
1412844901457 DeferredSave.extensions.json DEBUG Save changes
1412844901457 DeferredSave.extensions.json DEBUG Save changes
1412844901500 addons.xpi DEBUG Updating database with changes to installed add-ons
1412844901500 addons.xpi-utils DEBUG Updating add-on states
1412844901500 addons.xpi-utils DEBUG Writing add-ons list
1412844901503 addons.xpi DEBUG Registering manifest for C:\Users\CAIYON~1\AppData\Local\Temp\anonymous7467163378569626774webdriver-profile\extensions\commonfix@mozillaonline.com.xpi
1412844901503 addons.xpi DEBUG Calling bootstrap method startup on commonfix@mozillaonline.com version 0.9
1412844901537 addons.xpi DEBUG Registering manifest for C:\Users\CAIYON~1\AppData\Local\Temp\anonymous7467163378569626774webdriver-profile\extensions\semodifier@mozillaonline.com.xpi
1412844901538 addons.xpi DEBUG Calling bootstrap method startup on semodifier@mozillaonline.com version 0.2
1412844901538 addons.xpi DEBUG Registering manifest for C:\Users\CAIYON~1\AppData\Local\Temp\anonymous7467163378569626774webdriver-profile\extensions\wx-assistant@mozillaonline.com.xpi
1412844901538 addons.xpi DEBUG Calling bootstrap method startup on wx-assistant@mozillaonline.com version 1.1.1
1412844902639 DeferredSave.extensions.json DEBUG Starting timer
1412844902686 DeferredSave.extensions.json DEBUG Starting write
1412844902851 DeferredSave.extensions.json DEBUG Write succeeded
1412844902852 addons.xpi-utils DEBUG XPI Database saved, setting schema version preference to 16
1412844903056 addons.manager DEBUG shutdown
1412844903061 addons.xpi DEBUG shutdown
1412844903062 addons.xpi-utils DEBUG shutdown
1412844903063 addons.xpi DEBUG Notifying XPI shutdown observers
1412844903068 addons.manager DEBUG Async provider shutdown done
WARNING: At least one completion condition is taking too long to complete. Conditions: [{"name":"Sqlite.jsm shutdown blocker","state":{"description":"Waiting for connections to close"},"filename":"resource://gre/modules/Sqlite.jsm","lineNumber":84}] Barrier: profile-before-change
WARNING: At least one completion condition is taking too long to complete. Conditions: [{"name":"mo-ext-usage.sqlite Conn #0: waiting for shutdown","state":{"identifier":"mo-ext-usage.sqlite Conn #0","isCloseRequested":false,"hasDbConn":false,"hasInProgressTransaction":false,"pendingStatements":0,"statementCounter":19},"filename":"resource://gre/modules/Sqlite.jsm","lineNumber":366}] Barrier: Sqlite.jsm: wait until all connections are closed

Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:58'
System info: host: 'caiyongjun-PC', ip: '10.80.80.129', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_43'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:134)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:104)
at Test.webTest.main(webTest.java:21)
Caused by: org.openqa.selenium.WebDriverException: java.lang.InterruptedException: Process timed out after waiting for 45000 ms.
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:58'
System info: host: 'caiyongjun-PC', ip: '10.80.80.129', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_43'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.os.CommandLine.waitFor(CommandLine.java:131)
at org.openqa.selenium.firefox.FirefoxBinary.waitFor(FirefoxBinary.java:222)
at org.openqa.selenium.firefox.FirefoxBinary.clean(FirefoxBinary.java:242)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:91)
... 6 more
Caused by: java.lang.InterruptedException: Process timed out after waiting for 45000 ms.
at org.openqa.selenium.os.UnixProcess.waitFor(UnixProcess.java:148)
at org.openqa.selenium.os.CommandLine.waitFor(CommandLine.java:129)
... 9 more
求大神帮忙看看!!!!1
...全文
25511 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
白虹李李 2017-03-21
  • 打赏
  • 举报
回复
看到已经解决了。 不过除了加设置外,还有一个办法就是将firefox安装到默认路径去。 有的人加了那个property还是不行,可以试试这个办法。
wyn_2016 2017-03-15
  • 打赏
  • 举报
回复
请教大神 firefox版本是32的 而且加了那就system.setProperty,还是报错 说是找不到firefox 这个怎么解决啊
kasijia 2016-09-18
  • 打赏
  • 举报
回复
【从其他文章剪贴来的,很有用】selenium jar包和firefox浏览器版本对应关系 【Selenium】 -> 【FireFox】   2.25.0 -> 18   2.30.0 -> 19   2.31.0 -> 20   2.42.2 -> 29   2.44.0 -> 33 (不支持31,2014/12/1) 若selenium的版本和firefox不兼容,需要升级selenium的jar包,或者是升级firefox。 切记,关掉forefox的升级功能,否则连本地Windows上的脚本都跑不起来,且必须降级forefox。
Vin0502 2016-09-08
  • 打赏
  • 举报
回复
楼上正解,selenium版本可以用新版,但FF版本要用旧版本,新版本不支持
Candice_226 2016-08-05
  • 打赏
  • 举报
回复
可以使用selenium2.48+firefox42
baidu_27263417 2016-07-18
  • 打赏
  • 举报
回复
想知道怎么解决的
ezreal_tao 2016-03-18
  • 打赏
  • 举报
回复
System.setProperty("webdriver.firefox.bin","D:\\Program Files\\Mozilla Firefox\\firefox.exe"); 设置直接从安装位置启动
muyeheye 2015-12-11
  • 打赏
  • 举报
回复
楼主,你提的这问题解决了吗?
mmklyz 2015-12-03
  • 打赏
  • 举报
回复
已经添加了路径,运行时可以打开Firefox浏览器,但是再往下执行有问题,附代码: public void setUp() throws Exception { System.setProperty("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); driver = new FirefoxDriver(); baseUrl = "https://www.baidu.com/"; driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); }
qq_33115869 2015-11-25
  • 打赏
  • 举报
回复
我是selenium2.90+fireFox42是版本太高了吗?该如何解决
lz3364 2014-11-12
  • 打赏
  • 举报
回复
解决的方法找到了 在new FirefoxDriver之前加入这句: System.setProperty("webdriver.firefox.bin", "C:/Program Files (x86)/Mozilla Firefox/firefox.exe"); 后面是firefox的路径...貌似是找不到firefox...
lz3364 2014-11-12
  • 打赏
  • 举报
回复
同求...这有点蛋疼...
三平行者 2014-11-05
  • 打赏
  • 举报
回复
同问!顶贴,有哪位大神能帮忙解答下。
shuangyuessss 2014-10-15
  • 打赏
  • 举报
回复
同问 使用的是selenium 2.43+ FireFox 33.0 ,jar包和浏览器都是最新版本,也出现这个错误
幽影梦魇 2014-10-14
  • 打赏
  • 举报
回复
一定要selenium 2.39版本吗?为何2.43的报错啊
kedingka 2014-10-10
  • 打赏
  • 举报
回复
推荐 1. selenium 2.39+ FireFox 30.0 2. 并且在Firefox里设置 工具-->选项-->高级-->更新-->选中 【不检查更新】
kedingka 2014-10-10
  • 打赏
  • 举报
回复
jar包版本 和 浏览器版本不一致

5,177

社区成员

发帖
与我相关
我的任务
社区描述
软件工程/管理 质量管理/软件测试
功能测试压力测试安全性测试 个人社区 湖南省·长沙市
社区管理员
  • 软件测试
  • 虫无涯
  • 小博测试成长之路
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

欢迎大家加入到软件测试的社区,在这里,希望大家勇于发表自己的看法,欢迎大家分享自己在软件测试工作过程中遇到的问题以及工作经验分享。

1.想转行的小伙伴,遇到问题没有及时回复的,可以私聊小博进行反馈

2.大家对社区有好的建议,都可以在社区发帖进行反馈

推荐大家学习的软件测试入门笔记:软件测试入门学习笔记

试试用AI创作助手写篇文章吧