Зависает выполнение тестов при некоторой последовательности, при дебаге все нормально, воспроизводится в разных браузерах

Иногда некоторые тесты зависают, через какое то время chromedriver падает, 2016-07-04_1414

При дебаге - все нормально. Происходит не всегда и видимо при некоторых последовательностях. Тесты падают с такими ошибками:

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:49266 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, Dictionary2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.ExecuteScriptCommand(String script, String commandName, Object[] args)
at cutwiseSeleniumTests.model.PageBase.VerifyElementVisible(String elementName, IWebElement webElement) in C:\repos\cutwise-selenium-tests\src\CutwiseSeleniumTests\model\PageBase.cs:line 67
at cutwiseSeleniumTests.model.SortingMenu.VerifyExpectedElementsAreDisplayed() in C:\repos\cutwise-selenium-tests\src\CutwiseSeleniumTests\model\BlockPages\SortingMenu.cs:line 54
at cutwiseSeleniumTests.tests.SmokeForUnloggedPages.PageTest(PageBase page) in C:\repos\cutwise-selenium-tests\src\CutwiseSeleniumTests\tests\SmokeForUnloggedPages.cs:line 25

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> OpenQA.Selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
(Session info: chrome=52.0.2743.60)
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 10.0 x86_64)
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Remote.RemoteWebElement.get_Displayed() --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at OpenQA.Selenium.Support.PageObjects.WebDriverObjectProxy.InvokeMethod(IMethodCallMessage msg, Object representedValue) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at OpenQA.Selenium.IWebElement.get_Displayed() at cutwiseSeleniumTests.model.PageBase.VerifyElementVisible(String elementName, IWebElement webElement) in C:\repos\cutwise-selenium-tests\src\CutwiseSeleniumTests\model\PageBase.cs:line 34 Screenshot is here: C:\Users\tatya_000\AppData\Local\Temp\screenshot_2cc7540f-87fc-4111-8e5c-954bf4964399.png

Вот еще один запуск тестов:
`Test Name: View2x2Tile_VerifyExpectedElements
Test FullName: cutwiseSeleniumTests.tests.SmokeForUnloggedPages.View2x2Tile_VerifyExpectedElements
Test Source: C:\repos\cutwise-selenium-tests\src\CutwiseSeleniumTests\tests\SmokeForUnloggedPages.cs : line 73
Test Outcome: Failed
Test Duration: 0:03:23,57

Result StackTrace:
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Remote.RemoteWebDriver.FindElements(String mechanism, String value) at OpenQA.Selenium.Support.PageObjects.DefaultElementLocator.LocateElements(IEnumerable1 bys)
at OpenQA.Selenium.Support.PageObjects.WebElementListProxy.get_ElementList()
at OpenQA.Selenium.Support.PageObjects.WebElementListProxy.Invoke(IMessage msg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.Collections.Generic.IEnumerable1.GetEnumerator() at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at cutwiseSeleniumTests.model.View2X2Tile.IsDisplayed() in C:\repos\cutwise-selenium-tests\src\CutwiseSeleniumTests\model\BlockPages\View2x2Tile.cs:line 86
at cutwiseSeleniumTests.model.View2X2Tile.Invoke() in C:\repos\cutwise-selenium-tests\src\CutwiseSeleniumTests\model\BlockPages\View2x2Tile.cs:line 74
at cutwiseSeleniumTests.tests.SmokeForUnloggedPages.PageTest(PageBase page) in C:\repos\cutwise-selenium-tests\src\CutwiseSeleniumTests\tests\SmokeForUnloggedPages.cs:line 22
at cutwiseSeleniumTests.tests.SmokeForUnloggedPages.View2x2Tile_VerifyExpectedElements() in C:\repos\cutwise-selenium-tests\src\CutwiseSeleniumTests\tests\SmokeForUnloggedPages.cs:line 75
–WebException
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
Result Message:
OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:59851/session/fb06dca3f5d48cdce6b66fc6a52737c9/elements timed out after 60 seconds.
----> System.Net.WebException : The request was aborted: The operation has timed out.

`

Обновите драйвер для начала

Я уже пол недели читаю о проблеме в интернете, драйвер у меня свежий, все библиотеки тоже последние стабильные версии. Запускаю и студию и драйверы из под админа.

Проблема есть и в других браузерах, что-то у меня с teardown/setup не в порядке может, хотя пыталась выборочно запускать тесты поштучно с разными setup в отдельных плейлистах - проблемы не было.

Свежая версия драйвера, которая подходит для вашей версии хрома - 22, у вас же - chromedriver=2.21.371459
Стектрейс ошибки говорит, что не был найден элемент - тут может быть виновато и само тестируемое приложение, что у вас с ожиданиями?

Драйвер обновлила, просто это было до написания первого сообщения. Сейчас уже точно. Проблема видимо кроется в Setup, т.к. дописав в TestBase

[OneTimeTearDown]
public void FixtureTearDown()
{
SwdBrowser.CloseDriver();
}

Все стало хорошо.

у меня два базовых класса с разными Setup
`[TestFixture]
public abstract class TestBaseWithoutAuth : TestBase
{
[SetUp]
public void GoToMainUrlAndLogOutIfNeed()
{
SwdBrowser.Driver.Url = Config.ApplicationMainUrl;

        if (MyPages.Header.IsLogged())
        {
            MyPages.Header.GoLogout();
        }
        MyPages.Header.IsLogged().Should().BeFalse();
    }
}`

Заметила, что появляется второй процесс Chromedrive. Кстати тесты не всегда падают, иногда просто замирают по непонятной причине.