Wednesday, April 30, 2025

c# – Operating Selenium not beneath a Testing Framework


I have been utilizing Selenium for some time however with a barely completely different scope (really constraints). As a substitute of operating a take a look at for a selected website, I am for example in filling in an online type from a 3rd get together website and get some consequence, for example downloading a file, to make sure its high quality. So, I am primarily excited by utilizing Selenium to work together with a browser. To date, so good. I have been capable of obtain what I wished.

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

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

Nonetheless, once I deployed and tried to run these 2 completely 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.Web.WebException: 
Unable to hook up with the distant server ---> System.Web.Sockets.SocketException:
No connection might be made as a result of the goal machine actively refused it 127.0.0.1:3227
   at System.Web.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Web.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& handle, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
   --- Finish of internal 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 kind this out.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

PHP Code Snippets Powered By : XYZScripts.com