1

Environment settings:

  • Target Framework - 6
  • Selenium.WebDriver.ChromeDriver -115.0.5790.17000
  • Selenium.WebDriver - 4.11.0
  • Chrome Version - 115.0.5790.171

I am trying to launch the chrome driver and getting below error:

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

Driver initialization code -

new WebDriverManager.DriverManager().SetUpDriver(new ChromeConfig());
driver = new ChromeDriver(); driver.Navigate().GoToUrl("www.google.com"); 

Not sure how to resolve this issue?

Tried with different version of Selenium webdriver. Still getting same error.

Naveen
  • 11
  • 2

3 Answers3

1

This error message...

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

...indicates that Selenium was unable to start the ChromeDriver service.


Solution with Selenium v4.10+ versions

You need to cross check if Selenium Manager is integrated within the current Test Framework or in any of the later versions of the Specflow Test Framework.

Selenium Manager which is now fully integrated with Selenium v4.10 and onwards, can silently download the matching ChromeDriver in the background and execute the test and you won't require WebDriverManager any more.

So your effective code block can be:

driver = new ChromeDriver(); 
driver.Navigate().GoToUrl("www.google.com");
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • We are already in Selenium 4.11 and it has been working fine for long time. It is causing issues from last 2 weeks. I am still struck with same issue. Note - I am able to start the Firfox browser , the problem is starting the Chrome Browser. – Naveen Aug 09 '23 at 12:01
0

The code you provided uses WebDriverManager to setup a ChromeDriver instance. You may need to

  • check the configuration that you set
  • check if the WebDriverManager is downloading the driver properly

Instead of using WebDriverManager, you may try to create the service by referring to the chromedriver.exe in the Assembly path.

    /// <summary>
    /// Get Assembly path
    /// </summary>
    /// <returns>Full path to the assembly</returns>
    protected static string GetAssemblyPath()
    {
        var codeBase = Assembly.GetExecutingAssembly().Location ?? throw new Exception();
        var uriBuilder = new UriBuilder(codeBase);
        var path = Uri.UnescapeDataString(uriBuilder.Path);
        return Path.GetFullPath(path);
    }


    /// <inheritdoc/>
    protected override IWebDriver MakeLocalWebDriver()
    {
        var service = ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(GetAssemblyPath()));
        var driver = new ChromeDriver(service, ChromeOptions, CommandTimeout);
        return driver;
    }
lorvindc
  • 69
  • 1
  • 7
0

The issue was to firewall that was implemented to our machine. Disabling the firewall fixed the issue. Thanks for the support.

Naveen
  • 11
  • 2