我正在尝试使用selenium webdriver使用Java代码调用Firefox,Firefox浏览器打开,然而,它没有运行任何测试并在一段时间后终止,并在下面显示错误消息。请帮忙。
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
ageURL":null,"contributors":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285- 3208198ce6fd}.xpi","installDate":1458533452604,"updateDate":1458533452604,"applyBackgroundUpdates":1,"skinnable":true,"size":22012,"sourceUR I":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales": [],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e- 13a3a9e97384}","minVersion":"45.0.1","maxVersion":"45.0.1"}],"targetPlatforms":[],"seen":true}
1459488151820 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1459488151821 DeferredSave.extensions.json DEBUG Save changes
1459488151821 addons.xpi DEBUG Updating database with changes to installed add-ons
1459488151821 addons.xpi-utils DEBUG Updating add-on states
1459488151823 addons.xpi-utils DEBUG Writing add-ons list
1459488151826 addons.xpi DEBUG Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features \loop@mozilla.org.xpi
1459488151827 addons.xpi DEBUG Calling bootstrap method startup on loop@mozilla.org version 0.1
1459488151838 addons.manager DEBUG Starting provider: <unnamed-provider>
1459488151838 addons.manager DEBUG Registering shutdown blocker for <unnamed-provider>
1459488151838 addons.manager DEBUG Provider finished startup: <unnamed-provider>
1459488151848 addons.manager DEBUG Registering shutdown blocker for XPIProvider
1459488151849 addons.manager DEBUG Provider finished startup: XPIProvider
1459488151849 addons.manager DEBUG Starting provider: LightweightThemeManager
1459488151849 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager
1459488151849 addons.manager DEBUG Provider finished startup: LightweightThemeManager
1459488151849 addons.manager DEBUG Starting provider: GMPProvider
1459488151853 addons.manager DEBUG Registering shutdown blocker for GMPProvider
1459488151854 addons.manager DEBUG Provider finished startup: GMPProvider
1459488151854 addons.manager DEBUG Starting provider: PluginProvider
1459488151854 addons.manager DEBUG Registering shutdown blocker for PluginProvider
1459488151854 addons.manager DEBUG Provider finished startup: PluginProvider
1459488151854 addons.manager DEBUG Completed startup sequence
1459488153145 DeferredSave.extensions.json DEBUG Starting write
1459488153406 addons.repository DEBUG No addons.json found.
1459488153406 DeferredSave.addons.json DEBUG Save changes
1459488153409 DeferredSave.addons.json DEBUG Starting timer
1459488153430 addons.manager DEBUG Starting provider: PreviousExperimentProvider
1459488153430 addons.manager DEBUG Registering shutdown blocker for PreviousExperimentProvider
1459488153430 addons.manager DEBUG Provider finished startup: PreviousExperimentProvider
1459488153433 DeferredSave.extensions.json DEBUG Write succeeded
1459488153433 addons.xpi-utils DEBUG XPI Database saved, setting schema version preference to 17
1459488153462 DeferredSave.addons.json DEBUG Starting write
1459488153602 DeferredSave.addons.json DEBUG Write succeeded
1459488181051 addons.xpi DEBUG Calling bootstrap method shutdown on loop@mozilla.org version 0.1
1459488181184 addons.manager DEBUG shutdown
1459488181185 addons.manager DEBUG Calling shutdown blocker for <unnamed-provider>
1459488181185 addons.manager DEBUG Calling shutdown blocker for XPIProvider
1459488181185 addons.xpi DEBUG shutdown
1459488181185 addons.xpi-utils DEBUG shutdown
1459488181186 addons.manager DEBUG Calling shutdown blocker for LightweightThemeManager
1459488181186 addons.manager DEBUG Calling shutdown blocker for GMPProvider
1459488181188 addons.manager DEBUG Calling shutdown blocker for PluginProvider
1459488181189 addons.manager DEBUG Calling shutdown blocker for PreviousExperimentProvider
1459488181191 addons.xpi DEBUG Notifying XPI shutdown observers
1459488181196 addons.manager DEBUG Async provider shutdown done
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:122)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:276)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:116)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:223)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:212)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
at com.escttest.Test5.beforeClass(Test5.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:207)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:178)
答案 0 :(得分:2)
这是因为firefox的最新浏览器中出现了新问题。
更新您的硒罐。新版本的firefox(或不同的浏览器)不支持旧版的selenium。
下载Selenium Server(以前的Selenium RC Server)Selenium Client&amp; WebDriver语言绑定
用您正在使用的旧罐子替换它们。同时更新您的mozilla,以便获得更新的结果
来源: - http://docs.seleniumhq.org/download/
要解决此问题,您还需要将setPreference设置为xpinstall.signatures.required", false
到firefox配置文件,然后将其传递给驱动程序对象
firefoxProfile.setPreference("xpinstall.signatures.required", false);
下面的代码对我来说很好。
static WebDriver driver=null;
public static void main(String[] args) {
final FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("xpinstall.signatures.required", false);
driver = new FirefoxDriver(firefoxProfile);
driver.get("https://www.google.de/");
希望它会对你有所帮助:)。