我收到以下错误:
CurrentThread 需要将其 ApartmentState 设置为 ApartmentState.STA 才能使 Internet Explorer 自动化。
使用以下代码:
[TestClass]
public class UnitTest1
{
[AssemblyInitialize]
public static void AssemblySetup(TestContext context)
{
}
[TestMethod]
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("C:\\SomePath", "/")]
[UrlToTest("http://localhost/HomeView.aspx")]
public void TestMethod1()
{
using(IE ie = new IE("http://localhost/HomeView.aspx",true))
{
ie.TextField(Find.ById("MainContent_txtDLNumber")).TypeText("a235801945550");
}
}
}
将 WatIn 与 MsTest 结合使用是否有不同的方法?