使用SpecRun时,WatiN会抛出错误

时间:2012-03-22 12:28:37

标签: watin specflow

我尝试通过Nugget安装SpecRun。当我运行我的功能时,我收到以下错误:

[ERROR] Get to the Contact Page: The CurrentThread needs to have it's ApartmentState set to ApartmentState.STA to be able to automate Internet Explorer.

System.Threading.ThreadStateException:CurrentThread需要将它的ApartmentState设置为ApartmentState.STA才能自动化Internet Explorer。      在WatiN.Core.IE.CheckThreadApartmentStateIsSTA()      在WatiN.Core.IE.CreateNewIEAndGoToUri(Uri uri,IDialogHandler logonDialogHandler,Boolean createInNewProcess)      在WatiN.Core.IE..ctor()

任何想法如何解决这个问题?

其他信息:

研究

根据http://watin.org/documentation/sta-apartmentstate/,您需要在使用WatiN时将Thread.Apartmentstate设置为STA。但是,为了使用上一个链接中未提及的测试运行器,您需要通过电子邮件发送它们(已发送电子邮件)。

我的App.config具有以下内容:

  <specFlow>
    <!-- For additional details on SpecFlow configuration options see https://github.com/techtalk/SpecFlow/wiki/Configuration -->
    <unitTestProvider name="SpecRun" runtimeProvider="TechTalk.SpecRun.SpecFlowPlugin.SpecRunRuntimeProvider, TechTalk.SpecRun.SpecFlowPlugin" generatorProvider="TechTalk.SpecRun.SpecFlowPlugin.Generator.SpecRunGeneratorWith, TechTalk.SpecRun.SpecFlowPlugin.Generator" />
    <trace traceTimings="false" listener="TechTalk.SpecRun.SpecFlowPlugin.SpecRunListener, TechTalk.SpecRun.SpecFlowPlugin" />
  </specFlow>

1 个答案:

答案 0 :(得分:1)

现在,SpecRun version 0.14.0

的新版本中引入了STA支持

来自release notes

    0.14.0 - 2012/04/20 
    - Extended beta expiration until 30/05/2012 
    New features: 
    ...
    - Support for STA/MTA apartment state through the execution settings 
    of the profile: <Execution apartmentState="STA" />
所以现在应该和Watin一起工作。