1

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>


 

   
user5199
  • 359
  • 2
  • 15
  • Why would you need to wait for over 10 mins in an automated test? – JeffC Sep 19 '17 at 18:25
  • Nature of application. There is something being processed by a third party system and it can take up to an hour before that process to complete – user5199 Sep 19 '17 at 20:48
  • 1
    Then it doesn't sound like a good candidate for automation. – JeffC Sep 19 '17 at 20:49
  • I normally agree, but unfortunately the business wants us to continue the test flow that has this dependency, until the time to wait is fixed - which may take a while for developers to fix it. So how do I get around the timeout issue? – user5199 Sep 19 '17 at 21:10
  • I did discover that by playing around with some of the configs in the default.srprofile that I could get it to wait. But the caveat is that our multithreaded test runs in specflow would then become single threaded. Which is not ideal. So it seems like either a specflow limitation on threading with the wait for that long or there needs to be a specflow set I'm not aware of – user5199 Sep 19 '17 at 21:13
  • Can you run your script (script #1) that sets things in motion and then do something else (maybe run another script, do some SQL queries, etc.) later that verifies that script #1 was successful? – JeffC Sep 20 '17 at 00:04

1 Answers1

1

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

Andreas Willich
  • 5,665
  • 3
  • 15
  • 22