Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
8.5k views
by
edited by

I want to open a URL in already opened chrome browser without opening a new browser window in Selenium c#

Here is my code:

System.Uri uri = new System.Uri("http://localhost:7055/hub");
WebDriver = new RemoteWebDriver(uri, DesiredCapabilities.Firefox());

but I cant open URL in the already openend browser. Help me as soon as possible.

I am getting below error:

OpenQA.Selenium.WebDriverException: 'Unexpected error. 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:7055
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 ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)'

2 Answers

1 like 0 dislike
by

I encountered same issue when tried to use: WebDriver.Navigate().GoToUrl(url);

i found that my WebDriver instance doesn't get clean (get null) while the ChromeDriver had closed, so it use exist session of the previous WebDriver .

so in order to avoid this exception i check both 'WebDriver != null' and if the ChromeDriver is up, only if both are true i Don't create new ChromeDriver instance otherwise i do

0 like 0 dislike
by Contributing Tester (53 points)

Hi,
"Actively refused it" means that the host sent a reset instead of an ack when you tried to connect. It is therefore not a problem in your code. Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that port, this may be because it is not running at all or because it is listening on a different port.

once you start the process hosting your service try netstat -anb (requires admin privileges) to verify that it is running and listening on the expected port


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...