org.openqa.selenium.firefox.NotConnectedException:45000 ms后无法连接到端口7055上的主机127.0.0.1

时间:2013-05-03 06:16:05

标签: junit automated-tests selenium-rc

我正在尝试运行从Selenium IDE导出的Junit测试用例。我超越了异常。我正在使用Windows XP,Firefox 20.0.1,并使用selenium-server-standalone-2.28.0.jar.Upon运行,打开一个空白的Firefox窗口。当我关闭该窗口时,我在控制台

中得到以下异常
 org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms at
 org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:96)
 at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:142)
 at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:80)
 at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:121)
 at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:77)
 at com.dci.dids.selenium.SwamiRoleCreationTestCase.setUp(SwamiRoleCreationTestCase.java:20)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
 at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
 at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
 at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
 at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
 at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
 at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
 at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
 at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
 at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

JUnit失败跟踪中的此异常

 org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows: * LOG addons.xpi: startup LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID:
 /tmp/anonymous5690381165464188533webdriver-profile/extensions/webdriver-staging LOG addons.xpi: checkForChanges * LOG addons.xpi: No changes found

 System info: os.name: 'Linux', os.arch: 'i386', os.version: '3.2.0-23-generic-pae', java.version: '1.6.0_38' Driver info: driver.version:
 FirefoxDriver at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:108)
 at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:142)
 at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:80)
 at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:121)
 at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:77)
 at com.dci.dids.selenium.SwamiRoleCreationTestCase.setUp(SwamiRoleCreationTestCase.java:20)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
 at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
 at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
 at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
 at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
 at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
 at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
 at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
 at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
 at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:96) ... 25 more

 java.lang.NullPointerException at com.dci.dids.selenium.SwamiRoleCreationTestCase.tearDown(SwamiRoleCreationTestCase.java:47)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
 at org.junit.internal.runners.BeforeAndAfterRunner.runAfters(BeforeAndAfterRunner.java:65)
 at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:37)
 at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
 at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
 at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
 at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
 at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
 at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
 at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

7 个答案:

答案 0 :(得分:10)

您的Selenium版本可能与您的Firefox版本不兼容。尝试安装较旧的Firefox版本。

  1. 在安装和旧版本之前,请进入Firefox并关闭自动更新选项。

    Firefox - >选项 - >选项 - >高级 - >更新 - >检查更新,但让我选择安装

  2. 转到此处并安装旧版本。 https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/

    您不必卸载Firefox,只需安装要安装的版本即可。在获得正确版本之前,您可能需要尝试几个版本。

答案 1 :(得分:1)

我刚刚使用maven为WebDriver设置了JBehave这个问题。我强迫JBehave以下列方式使用更高版本的硒,这对我有用:

<dependency>
    <groupId>org.jbehave.web</groupId>
    <artifactId>jbehave-web-selenium</artifactId>
    <version>${jbehave.web.version}</version>
    <exclusions>
        <exclusion>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.33.0</version>
</dependency>

答案 2 :(得分:1)

所有提及的解决方案都不适用于我。对我有用的是使用最新的Firefox(目前是32.0.2)和最新的selenium

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.43.1</version>
    </dependency>

版本2.43.1工作,2.42.1没有。

答案 3 :(得分:0)

我有完全相同的问题,我通过将Firefox版本降级到27.0.1

解决了这个问题

答案 4 :(得分:0)

当WebDriver版本与Firefox版本不匹配时,java编译器会抛出此错误。确保您的WebDriver和Firefox都是最新版本。

答案 5 :(得分:0)

更新到selenium-server-standalone-2.44.0.jar适用于我(http://www.seleniumhq.org/download/)。

您似乎需要浏览器,selenium-driver和selenium-server的正确组合。

Ubuntu 14.04,Firefox 35.0.1和selenium-webdriver 2.44.0适用于Ruby on Rails应用程序。 自从我更新Chrome后,Chrome就无法运行,即使使用上次发布的驱动程序也是如此。

答案 6 :(得分:-3)

您需要卸载当前安装的Firefox。使用最低版本18.0.1重新安装FF这确实有效。