使用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.CommunicationObjectObjectFaultDexception:通信对象,System.ServiceModel.Channels.ServiceChannel,不能用于通信,因为它处于故障状态。
服务器堆栈跟踪: 在System.ServiceModel.Channels.CommunicationObject.throwiffaulted() at System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,布尔值,proxyoperationRuntime操作,对象[] ins,object [] outs,timespan超时) 在System.ServiceModel.Channels.Servicechannelproxy.invokeservice(Imethodcallmessage MethodCall,ProxyOperationRuntime操作) 在System.ServiceModel.Channels.Servicechannelproxy.invoke(iMessage消息)
异常在[0]中回复: 在System.Runtime.Remoting.proxies.RealProxy.HandLereturnMessage(iMessage reqmsg,iMessage retmsg) 在System.Runtime.Remoting.proxies.RealProxy.PrivateInVoke(Messagedata& msgdata,int32类型) 在TechTalk.specrun.framework.ioutproctastassemblyExecutor.runtests(testThreadState testThreadState) 在techtalk.specrun.framework.testthread.run(itestExeCutionManager executionManagerForrun)上 在TechTalk.specrun.framework.AsynctestTeStThreadRunner.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>
这是SpecFlow Runner中的一个错误,该错误将在版本1.6.3中固定。