Saturday, 15 March 2014

Using Specflow and Watin - have set the STA-thread, still get a System.Threading.ThreadStateException -



Using Specflow and Watin - have set the STA-thread, still get a System.Threading.ThreadStateException -

i'm writing ui-tests specflow , watin. have done next ensure watin work

setting thread.apartmentstate in app.config

<configuration> <configsections> <section name="specflow" type="techtalk.specflow.configuration.configurationsectionhandler, techtalk.specflow" /> <sectiongroup name="nunit"> <section name="testrunner" type="system.configuration.namevaluesectionhandler"/> </sectiongroup> </configsections> <nunit> <testrunner> <!-- valid values sta,mta. others ignored. --> <add key="apartmentstate" value="sta" /> </testrunner> </nunit> </configuration>

in properties interopshdocvw i've set "embeded interop types" false , "copy local" true

my code looks this... code in () because i'm not allowed share credentials , urls site

the specflow feature

feature: company in order to earn money as a company i want the suer able shop our products scenario: log in given have navigated (a companys test website) , have entered (a username) , (a password) credentials when press log in so should have (permissions)

the teststeps written in watin

using nunit.framework; using system; using techtalk.specflow; using watin.core; namespace projectname.companyname.specs { [binding] [requiressta] public class companysteps { ie browser = new ie(); [given] public void given_i_have_navigated_to_url(string url) { browser.goto(url); } [given] public void given_i_have_entered_email_and_password_as_credentials(string email, string password) { browser.textfield(find.byname("username")).typetext(email); browser.textfield(find.bytext("password")).typetext(password); } [when] public void when_i_press_log_in() { browser.button(find.bytext("log in »")).click(); } [then] public void then_then_i_should_have_the_permission_permission(string permission) { browser.goto("the page permissions showing plain text"); assert.istrue(browser.containstext(permission)); } }

now, probelm, i've done things mentioned online prepare sta or interop exceptions, when run specflow/watin test, still exception sta thread:

system.reflection.targetinvocationexception : exception has been thrown target of invocation. ----> system.threading.threadstateexception : currentthread needs have it's apartmentstate set apartmentstate.sta able automate net explorer.

anyone have had same problem , has solution? have forgotten code parts? syntax wrong somewhere?

kindest regards , in advance help.

watin specflow sta

No comments:

Post a Comment