Friday, March 28, 2025

c# – Working Selenium not underneath a Testing Framework


I have been utilizing Selenium for some time however with a barely totally different scope (truly constraints). As a substitute of operating a check for a selected web site, I am for example in filling in an online type from a 3rd social gathering web site and get some consequence, for example downloading a file, to make sure its high quality. So, I am primarily involved in utilizing Selenium to work together with a browser. To date, so good. I have been in a position to obtain what I needed.

So, as I am not involved in “testing” utilizing a Unit Testing Framework like MSTest, I began to make use of Selenium in a standard C# console utility. That labored nice!

Afterwards, as a substitute of launching Selenium from a Console I attempted to do it from: 1) a WCF Utility; and likewise from 2) an ASP.NET Internet Utility.
These 2 approaches labored effective whereas being launched from inside Visible Studio.

Nevertheless, once I deployed and tried to run these 2 totally different approaches the Seleniumn InternetExplorerDriver server (the identical with chromedriver) was by no means launched versus what occurred when being run from the Console Utility.

I am getting the next error:

OpenQA.Selenium.WebDriverException: A exception with a null response was thrown
sending an HTTP request to the distant WebDriver server for URL
http://localhost:3227/session//window. The standing of the exception was ConnectFailure,
and the message was: Unable to hook up with the distant server ---> System.Internet.WebException: 
Unable to hook up with the distant server ---> System.Internet.Sockets.SocketException:
No connection might be made as a result of the goal machine actively refused it 127.0.0.1:3227
   at System.Internet.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Internet.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& deal with, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
   --- Finish of interior exception stack hint ---

I am caught there. I guess it could must do with who’s the Host from the place the Selenium Internet Server is being run and their privileges. That is whether or not it’s a Console, a WCF App or an ASP.NET Internet App (hosted in IIS) however I do not know what to do or the place to look to type this out.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles