WatiN throws an error when using SpecRun
I tried to install SpecRun via Nugget. When I run my functions, I get the following error:
[ERROR] Get to the Contact Page: The CurrentThread needs to have it ApartmentState set to ApartmentState.STA to be able to automate Internet Explorer.
System.Threading.ThreadStateException: CurrentThread must have it for ApartmentState to set to ApartmentState.STA to be able to automate Internet Explorer. at WatiN.Core.IE.CheckThreadApartmentStateIsSTA () at WatiN.Core.IE.CreateNewIEAndGoToUri (Uri uri, IDialogHandler logonDialogHandler, Boolean createInNewProcess) at WatiN.Core.IE..ctor ()
Any ideas how to fix this?
Additional Information:
Study
According to http://watin.org/documentation/sta-apartmentstate/ you need to set Thread.ApartmentState to STA when using WatiN. However, in order to use a test runner that was not mentioned in the previous link, you need to email them (an email has already been sent).
My App.config has the following:
<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>
source to share
STA support is now available in the new SpecRun version 0.14.0
From the 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.
source to share