I have extracted the following code from selenium IDE.(c# remote control)
using System; using System.Text; using System.Text.RegularExpressions; using System.Threading; using NUnit.Framework; using Selenium; namespace SeleniumTests { [TestFixture] public class MyFirstVCTest { private ISelenium selenium; private StringBuilder verificationErrors; [Test] public void TheNewTest() { selenium.Open("/"); } [SetUp] public void SetupTest() { selenium = new DefaultSelenium("localhost", 4444, "*chrome","http://demo.volunteercampaigns.com/"); selenium.Start(); verificationErrors = new StringBuilder(); } [TearDown] public void TeardownTest() { try { selenium.Stop(); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", verificationErrors.ToString()); } [Test] public void TheMyFirstVCTest() { selenium.Open("/?AspxAutoDetectCookieSupport=1"); selenium.Click("link=Login"); selenium.WaitForPageToLoad("30000"); selenium.Type("id=ctl00_ContentPlaceHolder1_txtEmailAddress", "[email protected]"); selenium.Type("id=ctl00_ContentPlaceHolder1_txtPassword", "orbs123"); selenium.Click("id=ctl00_ContentPlaceHolder1_btnlogin"); selenium.WaitForPageToLoad("30000"); selenium.Click("id=ctl00_lblUserName"); selenium.Click("id=ctl00_lnkSignOut"); selenium.WaitForPageToLoad("30000"); } } }
i created a webform and added a button there.
in button click event i wrote this code
SeleniumTests.MyFirstVCTest m = new SeleniumTests.MyFirstVCTest(); m.SetupTest(); m.TheMyFirstVCTest(); m.TeardownTest();
i included all .dll files. its running fine(no errors and warnings).
but after clicking button i am getting the following error
No connection could be made because the target machine actively refused it 127.0.0.1:4444
what should i do??
thanks in advance..
Note to viewers: This post may help you : No connection could be made because the target machine actively refused it
You can try below solution: You might have a firewall rule in the way, or are trying to run it through a proxy without having the proxy up and running. The easiest way to check would be to disable your firewall or proxy and try again. Disable proxy at web.
Try running netstat -anb from the command line to see if there's anything listening on the port you were entered. If you get nothing, try changing your port number and see if that works for you. In Windows operating systems, you can use the netstat services via the command line (cmd.exe) .
“No connection could be made because the target machine actively refused it.” Generally, it happens that something is preventing a connection to the port or hostname. Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that specific port.
"...the target machine actively refused it" means the server could be reached and responded within the timeout, but the specified port wasn't open. This can have several reasons, e.g. a local firewall blocking the connection. Are you sure the server is listening on the right IP/port?
To add more clarity for the readers: Start selenium server using the followings basic steps:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With