7

I would kindly like to ask for help an issue I have running selenium on on a windows server without an interface, I get the following error:

Cannot start the driver service on http://localhost:49906/ at OpenQA.Selenium.DriverService.Start() at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout) at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)

Gustav
  • 53,498
  • 7
  • 29
  • 55
THATO MOLEFE
  • 71
  • 1
  • 1
  • 3

6 Answers6

1

Changed my Target Framework to .NET Core 2.1 (previously set to .net core 3.0) now its working.

Suresh Bhandari
  • 109
  • 1
  • 3
1

As I wrote here:

When the service start the only things executed are a process with the driver service and an api call to that service.
The problems that can rise could be:

  • you can't execute the process, because the executable is not reachable
    • executable not there
    • wrong permissions
  • some configurations are preventing you from executing successfully the api call and reach http://localhost:60623/
    • proxy settings (adding NO_PROXY environment variable excluding localhost might help)
    • firewall settings
    • port already used
Giulio Caccin
  • 2,962
  • 6
  • 36
  • 57
1

In my case, it was because there are too many background chrome process running. Run cmd as admin and use taskkill /f /im chromedriver.exe to kill all chrome driver instances and use taskkill /f /im chrome.ext /t to kill all chrome instances made it work.

Grace
  • 33
  • 1
  • 7
0

Browser opened with Selenium requires to run in Session 0 (GUI interface in Windows). Most possible that error that you provided is references to this problems.

You can try to solve Session 0 problem with running browser in headless mode, as it doesn't require to render in UI.

How to do it you can check it with this link Headless Chrome

Werewolfas
  • 46
  • 4
  • I ran it in headless mode and I still get the error – THATO MOLEFE Sep 18 '18 at 10:28
  • After some research in the internet I found that similar problem was registered in Selenium GitHub. Can you please check if this solution will work for you [OpenQA.Selenium.WebDriverException : Cannot start the driver service on http://localhost/](https://github.com/SeleniumHQ/selenium/issues/5293) If this solution does not work can you please provide source code for you WebDriver initialization. – Werewolfas Sep 18 '18 at 14:13
0

Having a VPN client running? In order to fully isolate (for amateurs), the loopback both as Ip and/or hostname are not directly accessible (unless the client is giving a possibility to exclude localhost or 127.0.0.1(and its Ipv6 equivalent) - was freaking me out once like crazy when i couldnt get the driver to work just because I still had my Cyberghost client running, but back to the most likely reason:

Especially when working a lot with ports, and possibily a ton of drivers, manually managing ports or at least manually checking/setting the port for the driver service can help.

I do this like this: I get all currently active TcpConnections(local endpoints). I create a random port from a given range for the driver service until the assigned port is not currently being used.

var ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();
var tcpConnInfoArray = ipGlobalProperties.GetActiveTcpConnections();
do
{
   driverService.Port = Random.Next(29999,65535);
} while (tcpConnInfoArray.Any(d => d.LocalEndPoint.Port == driverService.Port));
0

It seems that Selenium hosts a webserver on the localhost, which is not accessible. I disabled using a proxy for local addresses, and this solved the problem.

Tamás Kovács
  • 263
  • 5
  • 7