Specrun timeout on test execution when performing a selenium wait longer than 10 mins

736 views Asked by At

Using Specrun 1.5.2 with Specflow 2.1.0 to run my tests. I am having issues where the test keeps aborting using selenium to wait for a long amount of time(because I have to and there is now way around it presently).

WebDriverWait wait = new WebDriverWait(_driver, TimeSpan.FromHours(1));
                
                wait.PollingInterval = TimeSpan.FromMinutes(10);
                wait.Timeout = TimeSpan.FromHours(1);
                //TimeSpan.MaxValue.TotalHours
                wait.IgnoreExceptionTypes(typeof(ThreadAbortException));
                wait.IgnoreExceptionTypes(typeof(NoSuchElementException));
         
    wait.Until(ExpectedConditions.TextToBePresentInElementLocated(By.XPath($"//*[@data-ths=\"engagement_{EngagementId}\"]/../div[1]/span[2]"), "Ready"));

Whether I run the test from the command line or from within Visual Studio Enterprise using C#, I get the following exception:

TechTalk.SpecRun.Framework.SpecRunException: At least one test thread aborted. ---> System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

Server stack trace: at System.ServiceModel.Channels.CommunicationObject.ThrowIfFaulted() at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at TechTalk.SpecRun.Framework.IOutProcTestAssemblyExecutor.RunTests(TestThreadState testThreadState) at TechTalk.SpecRun.Framework.TestThread.Run(ITestExecutionManager executionManagerForRun) at TechTalk.SpecRun.Framework.AsyncTestThreadRunner.RunSync(TestExecutionManager executionManager) --- End of inner exception stack trace --- Result: test framework error: At least one test thread aborted. Total: 1 (test executions: 0) Succeeded: 0 Ignored: 0 Pending: 0 Skipped: 0 Failed: 0

> Here is my default.srprofile after removing 'apartmentStatew' parameter hoping it would resolve it:

<?xml version="1.0" encoding="utf-8"?>
<TestProfile xmlns="http://www.specflow.org/schemas/plus/TestProfile/1.5">
  <Settings projectName="Symphony.AcceptanceTests" projectId="{04deb5e2-c1a0-4b15-930d-8247c4d4954b}" />
  <Execution retryFor="None" stopAfterFailures="-1" testThreadCount="3" testSchedulingMode="Sequential" />
  <!--<Execution retryFor="None" stopAfterFailures="-1" testSchedulingMode="Sequential" />-->
  <Environment testThreadIsolation="Process" />

  <TestAssemblyPaths>
    <TestAssemblyPath>Symphony.AcceptanceTests.dll</TestAssemblyPath>
  </TestAssemblyPaths>
  <DeploymentTransformation>
    <Steps>
      <RelocateConfigurationFile target="CustomConfig{TestThreadId}.config" />
      <ConfigFileTransformation configFile="Symphony.AcceptanceTests.dll.config" >
        <Transformation>
          <![CDATA[<?xml version="1.0" encoding="utf-8"?>
       <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
                              <appSettings>
                                <add key="browser" value="{Target}" 
                                 xdt:Locator="Match(key)" xdt:Transform="SetAttributes(value)" />
                              </appSettings>
       </configuration>
      ]]>
        </Transformation>
      </ConfigFileTransformation>
    </Steps>
  </DeploymentTransformation>

  <Targets>
    <Target name="Edge">
      <Filter>Browser_Edge</Filter>
    </Target>
    <Target name="GhostDriver">
      <Filter>Ghost_Driver</Filter>
    </Target>
    <Target name="Chrome">
      <Filter>Browser_Chrome</Filter>
    </Target>
    <Target name="Firefox">
      <Filter>Browser_Firefox</Filter>
    </Target>
    <Target name="Safari">
      <Filter>Browser_Safari</Filter>
    </Target>
    <Target name="API">
      <Filter>API</Filter>
    </Target>
    <Target name="IE">
      <Filter>Browser_IE</Filter>
    </Target>
  </Targets>

  <TestThreads>
    <TestThread id="0">
      <TestAffinity>testPath:Target:Chrome</TestAffinity>
    </TestThread>
    <TestThread id="1">
      <TestAffinity>testPath:Target:API</TestAffinity>
    </TestThread>
    <TestThread id="2">
      <TestAffinity>testPath:Target:Edge</TestAffinity>
    </TestThread>
  </TestThreads> 
</TestProfile>


 

   

1

There are 1 answers

0
Andreas Willich On

This was a bug in the SpecFlow+Runner which will be fixed in version 1.6.3.