109

I am getting error while using Firefox with WebDriver.

org.openqa.selenium.firefox.NotConnectedException: Unable to connect
to host 127.0.0.1 on port 7055 after 45000 ms.
  • Firefox version:47.0
  • Selenium:2.53.0
  • Windows 10 64 bit

Is anyone getting a similar issue or any idea what is the solution for this? It's working fine with Chrome but with Firefox none of the URLs are getting loaded.

Boni García
  • 4,618
  • 5
  • 28
  • 44
veena k
  • 1,191
  • 2
  • 7
  • 4
  • 1
    Yes me too getting the same error. I'm uninstalling and reinstalling it again. If your browser is open, reset it and try. – Kishan Patel Jun 08 '16 at 04:37
  • Hi Kishan, I tried as you mentioned but still the same error...so I have downgraded to 46.0.1 – veena k Jun 09 '16 at 00:47
  • Yeah. there was some show stopper issue from mozilla. they updated the version. You can again rollback to 47. :-) – Kishan Patel Jun 09 '16 at 02:58
  • 1
    Possible duplicate of [Can't open browser with Selenium after Firefox update](http://stackoverflow.com/questions/37761668/cant-open-browser-with-selenium-after-firefox-update) – Mobrockers Jun 21 '16 at 06:36
  • 1
    This problem manifests itself on OSX with an error, '"Firefox.bin" can't be opened because the identity of the developer cannot be confirmed:'. Downgrading to 46 resolved it. – hoosteeno Jun 23 '16 at 17:42
  • Reffer: http://stackoverflow.com/questions/37761668/cant-open-browser-with-selenium-after-firefox-update – Alexa Iulian Jul 21 '16 at 19:31
  • Basically, I think browser automation should rely on an authentication mechanism, which is not provided by selenium or any browser, I know. So browser developers will always consider such automation interface as security gap, and we have this endless Tom and Cherry game with selenium one step behind. Whatever solution you get here, it's just for the day :( – Sam Ginrich Mar 09 '22 at 09:23

15 Answers15

94

Unfortunately Selenium WebDriver 2.53.0 is not compatible with Firefox 47.0. The WebDriver component which handles Firefox browsers (FirefoxDriver) will be discontinued. As of version 3.0, Selenium WebDriver will need the geckodriver binary to manage Firefox browsers. More info here and here.

Therefore, in order to use Firefox 47.0 as browser with Selenium WebDriver 2.53.0, you need to download the Firefox driver (which is a binary file called geckodriver as of version 0.8.0, and formerly wires) and export its absolute path to the variable webdriver.gecko.driver as a system property in your Java code:

System.setProperty("webdriver.gecko.driver", "/path/to/geckodriver");

Luckily, the library WebDriverManager can do this work for you, i.e. download the proper Marionette binary for your machine (Linux, Mac, or Windows) and export the value of the proper system property. To use this library, you need to include this dependency into your project:

<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>5.1.0</version>
</dependency>

... and then execute this line in your program before using WebDriver:

WebDriverManager.firefoxdriver().setup();

A complete running example of a JUnit 4 test case using WebDriver could be as follows:

public class FirefoxTest {

    protected WebDriver driver;

    @BeforeClass
    public static void setupClass() {
        WebDriverManager.firefoxdriver().setup();
    }

    @Before
    public void setupTest() {
        driver = new FirefoxDriver();
    }

    @After
    public void teardown() {
        if (driver != null) {
            driver.quit();
        }
    }

    @Test
    public void test() {
        // Your test code here
    }
}

Take into account that Marionette will be the only option for future (for WebDriver 3+ and Firefox 48+), but currently (version 0.9.0 at writing time) is not very stable. Take a look to the Marionette roadmap for further details.

UPDATE

Selenium WebDriver 2.53.1 has been released on 30th June 2016. FirefoxDriver is working again with Firefox 47.0.1 as browser.

Boni García
  • 4,618
  • 5
  • 28
  • 44
  • 9
    This is incorrect. MarionetteDriver is actually NOT supported in 47, despite the fact that FirefoxDriver is broken. Apparently 47.0.1 will be released (sometime) in which FirefoxDriver will be working again. Working MarionetteDriver did not make it into 47 as expected. See https://github.com/mozilla/geckodriver/issues/89 and https://bugzilla.mozilla.org/show_bug.cgi?id=1279950 - Note: I'm not saying MarionettDriver won't work at all, just that it is broken for a TON of use cases with 47. Downgrade is the only option as of today. – dmansfield Jun 15 '16 at 13:25
  • 7
    I updated to 47.0.1 and Selenium is still not connecting to Firefox. It no longer crashes Firefox, but I still get a failure to connect to 127.0.0.1:7055. When I run TcpView, there is no listener of port 7055 after Firefox starts up. – BardMorgan Jun 28 '16 at 20:37
  • 2
    I see the same behavior as BardMorgan, using Mac, Mono and Selenium .NET 2.53.0. Firefox 47.0.1 starts, but I get the timeout error _OpenQA.Selenium.WebDriverException: Failed to start up socket within 45000 milliseconds. Attempted to connect to the following addresses: 127.0.0.1:7055_ – netstat shows no listener to that port. – Otto G Jun 28 '16 at 21:19
  • 1
    And I have now also tested under Windows 10 and native .NET, and the problem is the same. Netstat shows that Selenium tries to connect, but no service is listening: `C:\Windows\system32>netstat -ano | find "7055" TCP 127.0.0.1:2896 127.0.0.1:7055 SYN_SENT 2052` – Otto G Jun 29 '16 at 12:03
  • 1
    For the record, when visiting about:addons in Firefox 47.0.1 launched by Selenium 2.53.0, the Extensions tab will show “Firefox WebDriver is incompatible with Firefox 47.0.1.” This is due to max version being 47.0 in https://github.com/SeleniumHQ/selenium/blob/selenium-2.53.0/javascript/firefox-driver/extension/install.rdf – the head version is fixed, so a build of the latest Selenium code from GitHub should fix the problem. – Otto G Jun 30 '16 at 13:50
19

Try using firefox 46.0.1. It best matches with Selenium 2.53

https://ftp.mozilla.org/pub/firefox/releases/46.0.1/win64/en-US/
Mahbub Rahman
  • 1,295
  • 1
  • 24
  • 44
  • Thanks Rahman ..it is working now...but what if the requirement is work with the latest version. – veena k Jun 09 '16 at 00:22
  • If the solution works, can you please accept the answer? :-) – Mahbub Rahman Jun 09 '16 at 01:29
  • 8
    thats not a solution, is downgrade to a previous version. – TiGreX Jun 09 '16 at 10:44
  • 1
    I did this too (but went to v45) - if you go down this path, make sure you rename \Mozilla Firefox\updater.exe to updater.exe.disable to prevent your downgraded version being upgraded back to the current version automatically. There may be other ways to achieve this too - but disabling updates in option settings did not work for me. – Drew Aug 02 '16 at 04:31
10

I had the same issue and found out that you need to switch drivers because support was dropped. Instead of using the Firefox Driver, you need to use the Marionette Driver in order to run your tests. I am currently working through the setup myself and can post some suggested steps if you'd like when I have a working example.

Here are the steps I followed to get this working on my Java environment on Mac (worked for me in my Linux installations (Fedora, CentOS and Ubuntu) as well):

  1. Download the nightly executable from the releases page
  2. Unpack the archive
  3. Create a directory for Marionette (i.e., mkdir -p /opt/marionette)
  4. Move the unpacked executable file to the directory you made
  5. Update your $PATH to include the executable (also, edit your .bash_profile if you want)
  6. :bangbang: Make sure you chmod +x /opt/marionette/wires-x.x.x so that it is executable
  7. In your launch, make sure you use the following code below (it is what I used on Mac)

Quick Note

Still not working as expected, but at least gets the browser launched now. Need to figure out why - right now it looks like I need to rewrite my tests to get it to work.

Java Snippet

WebDriver browser = new MarionetteDriver();
System.setProperty("webdriver.gecko.driver", "/opt/marionette/wires-0.7.1-OSX");
el n00b
  • 1,957
  • 7
  • 37
  • 64
6

If you're on OSX using Homebrew, you can install old Firefox versions via brew cask:

brew tap goldcaddy77/firefox
brew cask install firefox-46 # or whatever version you want

After installing, you'll just need to rename your FF executable in the Applications directory to "Firefox".

More info can be found at the git repo homebrew-firefox. Props to smclernon for creating the original cask.

Dan Caddigan
  • 1,578
  • 14
  • 25
6

If you're on a Mac do brew install geckodriver and off you go!

The Whiz of Oz
  • 6,763
  • 9
  • 48
  • 85
3

In case anyone is wondering how to use Marionette in C#.

FirefoxProfile profile = new FirefoxProfile(); // Your custom profile
var service = FirefoxDriverService.CreateDefaultService("DirectoryContainingTheDriver", "geckodriver.exe");
// Set the binary path if you want to launch the release version of Firefox.
service.FirefoxBinaryPath = @"C:\Program Files\Mozilla Firefox\firefox.exe";
var option = new FirefoxProfileOptions(profile) { IsMarionette = true };
var driver = new FirefoxDriver(
    service,
    option,
    TimeSpan.FromSeconds(30));

Overriding FirefoxOptions to provide the function to add additional capability and set Firefox profile because selenium v53 doesn't provide that function yet.

public class FirefoxProfileOptions : FirefoxOptions
{
    private DesiredCapabilities _capabilities;

    public FirefoxProfileOptions()
        : base()
    {
        _capabilities = DesiredCapabilities.Firefox();
        _capabilities.SetCapability("marionette", this.IsMarionette);
    }

    public FirefoxProfileOptions(FirefoxProfile profile)
        : this()
    {
        _capabilities.SetCapability(FirefoxDriver.ProfileCapabilityName, profile.ToBase64String());
    }

    public override void AddAdditionalCapability(string capabilityName, object capabilityValue)
    {
        _capabilities.SetCapability(capabilityName, capabilityValue);
    }

    public override ICapabilities ToCapabilities()
    {
        return _capabilities;
    }
}

Note: Launching with profile doesn't work with FF 47, it works with FF 50 Nightly.

However, we tried to convert our test to use Marionette, and it's just not viable at the moment because the implementation of the driver is either not completed or buggy. I'd suggest people downgrade their Firefox at this moment.

Steven
  • 2,258
  • 1
  • 22
  • 22
2

Its a FF47 issue https://github.com/SeleniumHQ/selenium/issues/2110

Please downgrade to FF 46 or below (or try out FF48 developer https://developer.mozilla.org/en-US/Firefox/Releases/48)

Instructions on how to downgrade: https://www.liberiangeek.net/2012/04/how-to-install-previous-versions-of-firefox-in-ubuntu-12-04-precise-pangolin/ Or if you are on Mac, as suggested by someone else in this thread use brew.

Supra
  • 1,612
  • 1
  • 18
  • 36
  • According to a comment 19 hours ago: “_Firefox 47.0.1 has been released with a fix. We now need to release client libraries to pick up a version bump in the xpi that is used by FirefoxDriver_.” That seems to explain why there are still problems with 2.53.0 and 47.0.1. – Otto G Jun 29 '16 at 16:00
2

New Selenium libraries are now out, according to: https://github.com/SeleniumHQ/selenium/issues/2110

The download page http://www.seleniumhq.org/download/ seems not to be updated just yet, but by adding 1 to the minor version in the link, I could download the C# version: http://selenium-release.storage.googleapis.com/2.53/selenium-dotnet-2.53.1.zip

It works for me with Firefox 47.0.1.

As a side note, I was able build just the webdriver.xpi Firefox extension from the master branch in GitHub, by running ./go //javascript/firefox-driver:webdriver:run – which gave an error message but did build the build/javascript/firefox-driver/webdriver.xpi file, which I could rename (to avoid a name clash) and successfully load with the FirefoxProfile.AddExtension method. That was a reasonable workaround without having to rebuild the entire Selenium library.

Otto G
  • 670
  • 7
  • 14
2

Firefox 47.0 stopped working with Webdriver.

Easiest solution is to switch to Firefox 47.0.1 and Webdriver 2.53.1. This combination again works. In fact, restoring Webdriver compatibility was the main reason behind the 47.0.1 release, according to https://www.mozilla.org/en-US/firefox/47.0.1/releasenotes/.

user7610
  • 25,267
  • 15
  • 124
  • 150
2

You can try using this code,

private WebDriver driver;
System.setProperty("webdriver.firefox.marionette","Your path to driver/geckodriver.exe");        
driver = new FirefoxDriver();

I upgraded to selenium 3.0.0 and Firefox version is 49.0.1

You can download geckodriver.exe from https://github.com/mozilla/geckodriver/releases

Make sure you download zip file only, geckodriver-v0.11.1-win64.zip file or win32 one as per your system and extract it in a folder.

Put the path for that folder in the "Your path to driver" quotes.Don't forget to put geckodriver.exe in the path.

suketup
  • 469
  • 7
  • 12
1

I eventually installed an additional old version of Firefox (used for testing only) to resolve this, besides my regular (secure, up to date) latest Firefox installation.

This requires webdriver to know where it can find the Firefox binary, which can be set through the webdriver.firefox.bin property.

What worked for me (mac, maven, /tmp/ff46 as installation folder) is:

mvn -Dwebdriver.firefox.bin=/tmp/ff46/Firefox.app/Contents/MacOS/firefox-bin verify

To install an old version of Firefox in a dedicated folder, create the folder, open Finder in that folder, download the Firefox dmg, and drag it to that Finder.

avandeursen
  • 8,458
  • 3
  • 41
  • 51
1

Here's what the problem looked like in Wireshark

Just load up 2.53.1 and every thing will work.

Community
  • 1
  • 1
JWP
  • 6,672
  • 3
  • 50
  • 74
1

As of September 2016

Firefox 48.0 and selenium==2.53.6 work fine without any errors

To upgrade firefox on Ubuntu 14.04 only

sudo apt-get update
sudo apt-get upgrade firefox
Levon
  • 10,408
  • 4
  • 47
  • 42
1

It seems to me that the best solution is to update to Selenium 3.0.0, download geckodriver.exe and use Firefox 47 or higher.

I changed Firefox initialization to:

 string geckoPathTest = Path.Combine(Environment.CurrentDirectory, "TestFiles\\geckodriver.exe");
 string geckoPath = Path.Combine(Environment.CurrentDirectory, "geckodriver.exe");
 File.Copy(geckoPathTest, geckoPath);
 Environment.SetEnvironmentVariable("webdriver.gecko.driver", geckoPath);
 _firefoxDriver = new FirefoxDriver();
Tomas Kubes
  • 23,880
  • 18
  • 111
  • 148
0

I can confirm that selenium 2.53.6 works with firefox 44 for me on ubuntu 15.