3

I've been using Selenium for a while but with a slightly different scope (actually constraints). Instead of running a test for a particular site, I'm interested for instance in filling in a web form from a third party site and get some result, for instance downloading a file, to ensure its quality. So, I'm mainly interested in using Selenium to interact with a browser. So far, so good. I've been able to achieve what I wanted.

So, as I'm not interested in "testing" using a Unit Testing Framework like MSTest, I started to use Selenium in a normal C# console application. That worked great!

Afterwards, instead of launching Selenium from a Console I tried to do it from: 1) a WCF Application; and also from 2) an ASP.NET Web Application. Those 2 approaches worked fine while being launched from within Visual Studio.

However, when I deployed and tried to run those 2 different approaches the Seleniumn InternetExplorerDriver server (the same with chromedriver) was never launched as opposed to what happened when being run from the Console Application.

I'm getting the following error:

OpenQA.Selenium.WebDriverException: A exception with a null response was thrown
sending an HTTP request to the remote WebDriver server for URL
http://localhost:3227/session//window. The status of the exception was ConnectFailure,
and the message was: Unable to connect to the remote server ---> System.Net.WebException: 
Unable to connect to the remote server ---> System.Net.Sockets.SocketException:
No connection could be made because the target machine actively refused it 127.0.0.1:3227
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
   --- End of inner exception stack trace ---

I'm stuck there. I guess it may have to do with who is the Host from where the Selenium Web Server is being run and their privileges. That's whether it is a Console, a WCF App or an ASP.NET Web App (hosted in IIS) but I don't know what to do or where to look to sort this out.

4
  • See if the port 3227 is in use by some other application
    – PDHide
    Feb 19, 2020 at 9:49
  • Thanks @PDHide for that but I've already checked. Anyways, I'll check again just in case. Feb 19, 2020 at 10:02
  • Since you say this is not for testing and this is a testing forum, this question might get flagged as off topic. Can you edit your question to reflect it as testing appropriate?
    – Lee Jensen
    Feb 19, 2020 at 18:25
  • @LeeJensen I've stated I'm not interested in "testing" as I'm not using the "testing" mechanism (running Selenium from a Test Method & Test Runner). As I mentioned, I've launched Selenium from a Console and I'm having a problem when hosting it from different types of project which are my constraints. This does not imply I'm not using a testing tool as Selenium to ensure the Quality. I ask here as this forum is for QA and I am using a testing tool. The reason I'm not using the Testing mechanism is out of the scope of the problem and does not add any value to put in here as is a requirement. Feb 20, 2020 at 8:51

1 Answer 1

0

It can be several things. Are you trying to connect to a remote hub? If that is the case from your error it seems that is trying to connect to http://localhost:3227, to validate go to http://localhost:3227/grid/console to see if it loads the selenium console page. If not, another common issue is incompatibility of versions ob the selenium webdriver in your project and the version of the webdriver client.

3
  • No, I'm not using remote hub, just plain Selenium Webdriver. The incompatibility of versions could be an option but "I guess" it would not make sense that Selenium works when is launched from a Console but not from a WCF on the same machine. Feb 20, 2020 at 16:33
  • Are you sure that Visual Studio does not have a plugin that will start the Selenium server? I have not use selenium with C# for a long time and I don't know the status of tools and helpers.
    – JoMateix
    Feb 21, 2020 at 8:57
  • NO, I would say No. The Selenium Server is run because when in your code you instantiate the ExplorerDriver Class one of the parameters is the Path to the driver. In this case : IEDriverServer.exe. As I said: this works great deployed on a different machine (without VS) when launched from a Console App. I guess VS and a Console App may have some sort of privileges or configuration that enables to launch Selenium without issues and may not be the case of WCF service or ASP.NET Web Application. Feb 21, 2020 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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