【问题标题】:Selenium/Firefox not working硒/火狐不工作
【发布时间】:2016-04-01 05:34:44
【问题描述】:

我正在尝试使用 Java 代码通过 selenium webdriver 调用 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)

【问题讨论】:

  • 你使用的firefox和selenium是什么版本?
  • 你应该是最新的 selenium 版本,也许这个问题会解决
  • 请将您的 firefox 和 selenium api 更新到最新版本,它将解决您的问题

标签: java debugging selenium firefox selenium-webdriver


【解决方案1】:

这是因为最新的 Firefox 浏览器出现了新问题。

更新您的硒罐。新版本的firefox(或其他浏览器)不支持selenium的旧jar。

同时下载 Selenium Server(以前的 Selenium RC Server)Selenium Client 和 WebDriver 语言绑定

用您正在使用的旧罐子替换它们。也更新您的 Mozilla,以便您获得更新的结果

来源:-http://docs.seleniumhq.org/download/

为了解决这个问题,您还需要将 Preference 设置为 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/");

希望对你有帮助:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-13
    • 2017-03-03
    • 2012-04-12
    • 2012-09-28
    • 1970-01-01
    • 2016-01-05
    • 2023-03-22
    • 1970-01-01
    相关资源
    最近更新 更多