执行硒等待时间超过10分钟时,测试执行超时超时

时间:2017-09-19 18:05:14

标签: selenium-webdriver specrun

使用Specrun 1.5.2和Specflow 2.1.0运行我的测试。我遇到的问题是测试中断使用硒等待很长时间(因为我必须现在和现在的方法)。



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"));




  

无论是使用C#从命令行还是从Visual Studio Enterprise中运行测试,我都会遇到以下异常:

TechTalk.SpecRun.Framework.SpecRunException:至少有一个测试线程中止。 ---> System.ServiceModel.CommunicationObjectFaultedException:通信对象System.ServiceModel.Channels.ServiceChannel不能用于通信,因为它处于Faulted状态。

服务器堆栈跟踪:    在System.ServiceModel.Channels.CommunicationObject.ThrowIfFaulted()    在System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object [] ins,Object [] outs,TimeSpan timeout)    在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime操作)    在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

在[0]处重新抛出异常:    在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)    在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 type)    在TechTalk.SpecRun.Framework.IOutProcTestAssemblyExecutor.RunTests(TestThreadState testThreadState)    在TechTalk.SpecRun.Framework.TestThread.Run(ITestExecutionManager executionManagerForRun)    在TechTalk.SpecRun.Framework.AsyncTestThreadRunner.RunSync(TestExecutionManager executionManager)    ---内部异常堆栈跟踪结束--- 结果:测试框架错误:至少一个测试线程中止。   总计:1(测试执行次数:0)   成功:0   忽略:0   待定:0   跳过:0   失败: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>


 

   
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

这是SpecFlow + Runner中的一个错误,将在版本1.6.3中修复。