22

I'm trying to run a Junit Test case which i exported from Selenium IDE. Im getting above exception.I'm using Windows XP,Firefox 20.0.1,and using selenium-server-standalone-2.28.0.jar.Upon run, a blank Firefox window is opened. When I close that window i get below exception in console

 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)

This exception in JUnit Failure trace

 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)
Mallikarjuna Reddy
  • 1,212
  • 2
  • 20
  • 33
Prateek Mohan
  • 229
  • 1
  • 2
  • 5
  • 2
    This thread has it covered, I guess: [http://stackoverflow.com/questions/15814695/selenium-webdriver-does-not-connect-with-firefox-20][1] [1]: http://stackoverflow.com/questions/15814695/selenium-webdriver-does-not-connect-with-firefox-20 – patrungel May 03 '13 at 15:47
  • Although the answers below are correct at the time of post writing, it might be worthwhile to note that the FF Driver won't work for anything after FF 47 and that the [Marionette Driver should be used instead](http://stackoverflow.com/a/37728659/1992129). Posting as a comment since I came across this post before finding my answer in the linked post. I was having the same error, but with different versions of software. – Arthur Weborg Sep 27 '16 at 22:00

7 Answers7

10

Your version of Selenium is probably not compatible with your version of Firefox. Try installing an older Firefox version.

  1. Before installing and older version, go into Firefox and turn off the automatic update option.

    Firefox --> Options --> Options --> Advanced --> Update --> Check for updates, but let me choose to install them

  2. Go here and install and older version. https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/

    You don't have to uninstall Firefox, just install the version you want to install. You may have to try a few versions until you get the right one.

James Lawruk
  • 30,112
  • 19
  • 130
  • 137
  • I had faced exactly the same problem today using Selenium WebDriver 2.31 with FF 27.0.1. It is solved now with using WebDriver 2.39 with FF 27.0.1 – Ripon Al Wasim Apr 04 '14 at 05:03
  • 2
    or if the browser is a new version, update Selenium instead of installing old browser... – kiedysktos Jan 12 '16 at 22:03
1

I just had this problem setting up JBehave for WebDriver using maven. I forced JBehave to use a higher version of selenium in the following way, which works for me:

<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>
qkrijger
  • 26,686
  • 6
  • 36
  • 37
1

None of the mention solutions worked for me. What worked for me is to use latest Firefox (currently 32.0.2) and latest selenium

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

Version 2.43.1 worked, 2.42.1 did not.

igo
  • 6,359
  • 6
  • 42
  • 51
0

I had exactly the same problem, i solved it by downgrading Firefox version to 27.0.1

Shessuky
  • 1,846
  • 21
  • 24
0

When WebDriver version doesn't match the Firefox version, the java compiler throws this error. Make sure your WebDriver and Firefox both are the latest version.

ebarrenechea
  • 3,775
  • 1
  • 31
  • 37
0

Update to selenium-server-standalone-2.44.0.jar works for me (http://www.seleniumhq.org/download/).

It seems that you need a proper combination of browser, selenium-driver and selenium-server.

Ubuntu 14.04, Firefox 35.0.1 and selenium-webdriver 2.44.0 works for me in a Ruby on Rails app. Chrome didn't work since I updated it, even with the last released driver.

Aldo
  • 704
  • 6
  • 7
-3

You need to Uninstall the currently installed Firefox. Reinstall the FF with minimum version 18.0.1 This really works.