???????????????????????????貼????????????÷?????????Spec Flow???????????衣?????????????????????о??崠?趨?壺“Given I am at the ‘Login’page”??
[Given("I am at the 'Login' page")
public void GivenIAmAtTheLoginPage()
{
// TODO
}
??????????÷??????????????????????????Spec Flow??????????????裬??????趼?????????????κ????feature????е??????????????“Given”???????裬???????????“I am at the ‘Login’page”?????????÷???????
?????????????????ò??趨???д??????С????????????WatiN???????????????????????檔???????????????????????????????????????????scenario?????????????????????????????scenario?????в????????????????????????????????????????????????????????????ScenarioContext????С?ScenarioContext?????????????Scenario??й????е??????????????????????WebBrowser??helper??????????scenario????????????????
using TechTalk.SpecFlow;
using WatiN.Core;
static class WebBrowser
{
public static IE Current
{
get
{
if(!ScenarioContext.Current.ContainsKey("browser"))
ScenarioContext.Current["browser"] = new IE();
return ScenarioContext.Current["browser"] as IE;
}
}
}
?????????Helper????Current?????????????????????????????????е?scenario??????????ScenarioContext??????????????????????????????????????????????????????С???????????????е?????????????????
?????????????????????????????趨??????????????У????????????http://localhost:9876/authentication/login??????????????Scenario??????????λ????URL????????????趨?塣??????????????????????????????????????????????????趨?壬?????????????????????????????????????趨?壬??????????????????趨?????????????????????????
[Given("I am at the 'Login' page")
public void GivenIAmAtTheLoginPage()
{
// Make sure to add the namespace the WebBrowser class is inside
WebBrowser.Current.GoTo("http://localhost:9876/authentication/login");
}

??????β
???????????????????????????????????????????????????????е???趨?壬???????????????????????????????涼???????ν????????в??????????????????м???????е???????????ó???Copy Local??????????NuGet????WatiN??Interop.SHDocVw DLL??????????Embed Interop???????ó?True???????????????Embed Interop???????ó?false???????????????Copy Local???????ó?True??
???????????????????????Apartment State????%