0

I have a super simple test script (below) to get started with WebDriver. When I run the test (C# - Visual Studio 2015), it opens up a Firefox browser and then does nothing.

There are several posts out there that talk about the following issue, which I'm also getting:

OpenQA.Selenium.WebDriverException: Failed to start up socket within 45000 milliseconds. Attempted to connect to the following addresses: 127.0.0.1:7055.

But those posts regarding this problem are quite old and also have one major difference- their FF browser didn't open; mine does.

The error: enter image description here

The code:

using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;

namespace seleniumDemo
{
    [TestClass]
    public class UnitTest1
    {
        static IWebDriver driverFF;

        [AssemblyInitialize]
        public static void SetUp(TestContext context)
        {
            driverFF = new FirefoxDriver();
        }

        [TestMethod]
        public void TestFirefoxDriver()
        {
            driverFF.Navigate().GoToUrl("http://www.google.com");
            driverFF.FindElement(By.Id("lst-ib")).SendKeys("Selenium");
            driverFF.FindElement(By.Id("lst-ib")).SendKeys(Keys.Enter);
        }
    }
}

This question is different from what's been suggested as a duplicate because the FireFox browser actually opens in this case. In the other questions, it wasn't responding at all.

8protons
  • 3,591
  • 5
  • 32
  • 67
  • 1
    Version incompatibility most likely. Check that version of selenium you are using supports version of Firefox you have – timbre timbre Aug 31 '16 at 03:11
  • Have look here http://stackoverflow.com/questions/38676719/fail-to-launch-mozilla-with-selenium – Saurabh Gaur Aug 31 '16 at 06:21
  • 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 Aug 31 '16 at 08:47
  • --> https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/8543 – Andrejs Sep 11 '16 at 14:26

3 Answers3

0

it seems to be related to Selenium and Firefox version incompatibility. I also faced the same error when selenium on my machine was unable to communicate to firefox. I upgraded firefox to 46.x and it started working.

You can find version compatibility information over web or refer selenium changelog as well.

Rohit Garg
  • 493
  • 2
  • 12
0

Use MarrioneteDriver to use latest version of Firefox.

Below is the Java code, you can write in C# accordigly (Make sure you have geckodriver.exe under BrowserDriver folder in your project folder)

System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir")+"/BrowserDrivers/geckodriver.exe");
        DesiredCapabilities cap = DesiredCapabilities.firefox();
        cap.setCapability("marionette", true);
        WebDriver driver = new MarionetteDriver(cap);
QA Square
  • 245
  • 1
  • 3
0

You can download latest version of MarrioneteDriver from below :

https://github.com/mozilla/geckodriver/releases

And you should Marionette executable to Windows system path :

To add the Marionette executable to Windows system path you need update the Path system variable and add the full directory to the executable.

To do this, right-click on the Start menu and select System. On the left-side panel click Advanced system settings and then Environment Variables button from System Properties window. Now the only step left to do is to edit Path system variable and add the full directory to your geckodriver (you may need to add a semi-colon before doing this, if not already present) and you’re good to go.

Then simply create your driver instance :

var driver = new FirefoxDriver(new FirefoxOptions());
Bugra Cil
  • 25
  • 4