Home > Software engineering >  Cannot start firefox browser instance for tests using Visual Studio, C#, Nunit and Selenium
Cannot start firefox browser instance for tests using Visual Studio, C#, Nunit and Selenium

Time:02-23

I am having troubles trying to run simple UI test in Visual Studio (16.11.10) using C# and NUnit. I am using Selenium.Firefox.WebDriver version 0.27.0., Selenium.WebDriver and Selenium.Support both 4.1.0

Test:

using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;

namespace ClassLibrary2
{
    public class Class1
    {
        [Test]
        public static void TestBrowser()
        {
            IWebDriver driver = new FirefoxDriver();
            driver.Url = "https://login.yahoo.com/";
            driver.Quit();
        }

    }
}

Running this test I am getting such error:

 TestBrowser
   Source: Class1.cs line 10
   Duration: 4,6 sec

  Message: 
OpenQA.Selenium.WebDriverException : Cannot start the driver service on http://localhost:59898/

  Stack Trace: 
DriverService.Start()
DriverServiceCommandExecutor.Execute(Command commandToExecute)
WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
WebDriver.StartSession(ICapabilities desiredCapabilities)
WebDriver.ctor(ICommandExecutor executor, ICapabilities capabilities)
FirefoxDriver.ctor(FirefoxDriverService service, FirefoxOptions options, TimeSpan commandTimeout)
FirefoxDriver.ctor(FirefoxOptions options)
FirefoxDriver.ctor()
Class1.TestBrowser() line 18

  Standard Output: 
Unable to connect to the remote server

All works fine using ChromeDriver. Thanks for your help.

CodePudding user response:

Possibly Selenium.Firefox.WebDriver version 0.27.0 points to the older GeckoDriver of version0.27.0. Hence you see the error.

The solution would be to upgrade to latest version of GeckoDriver i.e. version0.30.0

  • Related