Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WatiN throws error when using SpecRun

Tags:

watin

specflow

I tried installing SpecRun via Nugget. When I run my features, I obtain the following error:

[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: The CurrentThread needs to have it's ApartmentState 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:

Research

According to http://watin.org/documentation/sta-apartmentstate/, you need to set the Thread.Apartmentstate to STA when using WatiN. However, in order to use a test runner that has not been mentioned in the previous link, you need to email them (email already 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>
like image 591
Karan Avatar asked Mar 16 '26 03:03

Karan


1 Answers

STA support is now introduced in the new release of 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" />
So it should work now with Watin.
like image 156
nemesv Avatar answered Mar 18 '26 03:03

nemesv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!