在我的Ubuntu工作站上本地运行使用Firefox的Selenium(Webdriver)测试不再有效。
以前完全相同的设置工作,但我认为Firefox在某个时候升级了(现在它是Ubuntu包16.0.2+build1-0ubuntu0.11.04.1
的16.0.2),之后它停止了工作。在正常使用中,Firefox工作正常。
使用Webdriver,当我运行测试用例(通过我的IDE)时,会打开一个空的Firefox窗口,但测试无法启动。 45秒后,它会超时,并显示以下错误消息:
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
*** LOG addons.xpi: startup
*** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous5012217980260937474webdriver-profile/extensions/webdriver-staging
*** LOG addons.xpi: checkForChanges
*** LOG addons.xpi-utils: Opening database
*** LOG addons.xpi: Add-on {2204c510-88f3-11db-b606-0800200c9a66} modified in app-profile
*** LOG addons.xpi: Add-on yslow@yahoo-inc.com modified in app-profile
*** LOG addons.xpi: Add-on {02450954-cdd9-410f-b1da-db804e18c671} modified in app-profile
*** LOG addons.xpi: Add-on {c45c406e-ab73-11d8-be73-000a95be3b12} modified in app-profile
*** LOG addons.xpi: Add-on {a6fd85ed-e919-4a43-a5af-8da18bda539f} modified in app-profile
*** LOG addons.xpi: Add-on pythonformatters@seleniumhq.org modified in app-profile
*** LOG addons.xpi: Add-on rubyformatters@seleniumhq.org modified in app-profile
*** LOG addons.xpi: Add-on javaformatters@seleniumhq.org modified in app-profile
*** LOG addons.xpi: Add-on csharpformatters@seleniumhq.org modified in app-profile
*** LOG addons.xpi: Add-on firebug@software.joehewitt.com modified in app-profile
*** LOG addons.xpi: Loading bootstrap scope from /tmp/anonymous5012217980260937474webdriver-profile/extensions/firebug@software.joehewitt.com.xpi
*** LOG addons.xpi: Calling bootstrap method install on firebug@software.joehewitt.com version 1.10.6
*** LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile
*** LOG addons.xpi: Updating database with changes to installed add-ons
*** LOG addons.xpi-utils: Updating add-on states
*** LOG addons.xpi-utils: Writing add-ons list
*** LOG addons.xpi: Calling bootstrap method startup on firebug@software.joehewitt.com version 1.10.6
*** LOG ubufox.urn: Starting
*** LOG addons.xpi: shutdown
*** LOG addons.xpi-utils: shutdown
*** LOG addons.xpi-utils: Database closed
*** LOG addons.xpi: startup
*** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /tmp/anonymous5012217980260937474webdriver-profile/extensions/webdriver-staging
*** LOG addons.xpi: checkForChanges
*** LOG addons.xpi: No changes found
*** LOG addons.xpi: Loading bootstrap scope from /tmp/anonymous5012217980260937474webdriver-profile/extensions/firebug@software.joehewitt.com.xpi
*** LOG addons.xpi: Calling bootstrap method startup on firebug@software.joehewitt.com version 1.10.6
*** LOG ubufox.urn: Starting
Build info: version: '2.23.1', revision: '17143', time: '2012-06-08 18:59:28'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.38-16-generic', java.version: '1.6.0_26'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:113)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:93)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:156)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:151)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:93)
at fi.company.product.testing.selenium.AbstractSeleniumTest.getFirefoxDriver(AbstractSeleniumTest.java:99)
at fi.company.product.testing.selenium.AbstractSeleniumTest.setup(AbstractSeleniumTest.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.runners.model.FrameworkMethod$1.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.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at fi.company.product.testing.selenium.ScreenshotTestRule$1.evaluate(ScreenshotTestRule.java:27)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:199)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
在我们的基础测试课程中,FirefoxDriver
的初始化方式如下:
new FirefoxDriver(new FirefoxProfile())
...虽然我也尝试使用相同的结果指向现有的Firefox配置文件目录(类似/home/jonik/.mozilla/firefox/vds3ono5.default
)。
如何让测试再次运行?
答案 0 :(得分:5)
v2.23不支持Firefox 16。您必须升级到v2.26,或降级Firefox。