2

I have problem with running selenium test on Internet Explorer 8.0. on Jenkins. Test fails, then many IEDriverServer.exe appear.

In logs: "No connection could be made because the target machine actively refused it"

What is problem?

Link to screenshot: many IEDriverServer

nathanchere
  • 8,008
  • 15
  • 65
  • 86
ahanoff
  • 130
  • 1
  • 7
  • 1
    Which language? Related: remember to [.quit to close the IE driver process](http://stackoverflow.com/a/11154803/1431750) – aneroid Sep 15 '12 at 06:27

1 Answers1

4

Yes, had exact same situation before, should do just like what aneroid said.

In your TestCleanUp() method, driver.Quit() should be called. Then if your test fails or exception is caught during the test body, test will still quit properly.

[TestClass]
public class IEDriverTest {

    private IWebDriver driver;

    [TestInitialize]
    public void Initialize() {
        driver = new InternetExplorerDriver();
    }

    [TestMethod]
    public void Test() {
        // test steps
    }

    [TestCleanup]
    public void CleanupTests() {
        driver.Quit();
    }
}

However, I found in some rare situations that some older versions of IEDriverServer hangs when exceptions are caught during TestInitialize time (using Visual Studio Testing Framework). Then you may need a bit special handling, which catches the exception and calls driver.Quit() manually.

If driver.Quit() doesn't work somehow. You may also try killing ie and IEDriverServer process manually. I would highly recommend you avoid doing this though.

[TestCleanup]
public void Cleanup() {
    KillProcessByName("iexplore");
    KillProcessByName("IEDriverServer");
}

private void KillProcessByName(string processName) {
    foreach (Process process in Process.GetProcessesByName(processName)) {
        process.Kill();
    }
}
Yi Zeng
  • 32,020
  • 13
  • 97
  • 125