I faced with problem of running several automated tests successive. When I run tests separately all works great, but if I run multiple tests simultaneously I get this error on second test (first is passed):
Result Message:
Test method IAM.DashboardTests.Tests.ChromeWizardTests.CheckAppsUsedByCoworkersChrome threw exception:
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 [::1]:59780
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.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
Note: tests are running on my machine, I don't use any remote machines.
All tests are placed in one class and it contains TestInitialize (MSTest annotation) with running driver and browser:
private void ChooseBrowser(String browser)
{
if (driver == null)
{
if ("firefox".Equals(browser))
{
driver = new FirefoxDriver();
}
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));
and TestCleanup with browser stopping:
public void Stop()
{
driver.Quit();
driver = null;
}
By the way, browser opens in second tests and goes to login page but after that error occurs. I mean that physically browser exists, but tests can interact with him. Reproduced in Chrome and Firefox on Windows8.
Please, let me some advice, I cannot beat this problem alone.