I am trying to port some Selenium-Tests that I developed under windows (my main platform) to Linux (Ubuntu 19.10 in a VM). I must admit, I'm not too familiar with the environment, so I might be missing very obvious things - well, obvious for those that live on Linux ;)

After fixing issues with file permissions for the driver etc., I am stopped with this exception:

OpenQA.Selenium.WebDriverException: An unknown exception was encountered sending an HTTP request to the remote WebDriver server for URL http://localhost:39213/session. The exception message was: Connection refused
 ---> System.Net.Http.HttpRequestException: Connection refused
 ---> System.Net.Sockets.SocketException (111): Connection refused
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
   at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
   --- End of inner exception stack trace ---
   at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
   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.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
   at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
   at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options)

when trying to instantiate ChromeDriver (by passing an instance of ChromeDriverService and some ChromeOptions.

How can I diagnose/fix this?

The webserver I would like to talk to listens on and delivers content to a regular browser. A coworker recommended to try netstat -an | grep 39213 to see if anything is actually listing on that port - which was not the case (no output from that command). And indeed - the service did not launch. I have an instance of ChromeDriverService - but there is no process associated with it. Will look into that now and update the question if I find anything useful...

  • What's the actual IP addr of localhost? And of your WebDriver server? Are they the same? Isn't onesth like and the other one – pavelsaman Jun 16 '20 at 13:29
  • In which machine your WebDriver server is running? Whether in local machine or else in some other remote machine – Mohamed Sulaimaan Sheriff Jun 16 '20 at 13:31
  • What is your linux distro? – Alexey R. Jun 16 '20 at 13:49
  • Have you started selenium server before running your script ? – PDHide Jun 16 '20 at 18:09
  • Answered 1 (partially) and 2+3 by adding to the question. Not sure what you guys mean with "Selenium Server". The "pattern" I learned on windows is to first create a ChromeDriverService and then pass that instance to the ChromeDriver. And it's all happening on this machine - no external calls needed. – MBaas Jun 17 '20 at 7:14

Argh - found it: the file chromedriver. did not have execute-permissions. That wasn't reported as a problem when I instantiated ChromeDriverService - but I also did not create a "regular instance" of it. After setting these permissions, it's running now!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.