我在Nunit测试中有以下代码...
string url = "";
url = @"http://localhost/ClientPortalDev/Account/LogOn";
ieStaticInstanceHelper = new IEStaticInstanceHelper();
ieStaticInstanceHelper.IE = new IE(url);
ieStaticInstanceHelper.IE.TextField(Find.ById("UserName")).TypeText("abc");
ieStaticInstanceHelper.IE.TextField(Find.ById("Password")).TypeText("defg");
ieStaticInstanceHelper.IE.Button(Find.ById("submit")).Click();
ieStaticInstanceHelper.IE.Close();在Dev10(visual studio 10)中右键单击项目并选择“测试方式”时,此测试代码运行时没有任何问题。我已经安装了TestDriven。
... LoginAsWellKnownUserShouldSucceed:
System.Runtime.InteropServices.COMException : Error HRESULT E_FAIL has been returned from a call to a COM component.顺便说一句。在Dev10中右键单击源cs文件,然后选择运行测试,...效果也很好。上面的测试实际上是TechTalk.SpecFlow 1.3步骤的一部分,我已经安装了NUnit 2.5.5.10112,我已经安装了Watin20.20,我已经为我的测试dll安装了以下App.config
起始角括号已被删除...如何让xml出现在
configuration>
configSections>
sectionGroup name="NUnit">
section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/>
/sectionGroup>
/configSections>
NUnit>
TestRunner>
add key="ApartmentState" value="STA" />
/TestRunner>
/NUnit>
appSettings>
add key="configCheck" value="12345" />
/appSettings>
/configuration>以前有人打过这个吗?显然,NUnit测试可以在TestDriven的NUnit 2.5.5中运行,但在Dev10和TestDriven之外运行NUnit 2.5.5时就不能了。
发布于 2010-06-04 00:38:39
以管理员身份在NUnit中运行测试。我以管理员身份运行Dev10,这样我就可以连接和调试w3ww,这就是TestDriven测试有效的原因。我一开始以管理员身份运行NUnit,COM服务器就会发出“离开”的问题。更令人困惑的是,即使NUnit不是以管理员身份运行的,在Watin站点上运行hello-world示例也能正常工作。
要对本地web服务器使用NUNit + Watin +,以管理员身份运行NUnit可解决com服务器异常问题。
发布于 2011-04-28 13:40:56
尝试在测试代码中使用RequiresSTA属性,而不是配置文件。
发布于 2013-11-26 22:45:16
我正在使用MSTest,调用Refresh来避免缓存数据,这对我很有效:
browser.Refresh();
browser.TextField(Find.ById("username")).TypeText("user");
browser.TextField(Find.ById("password")).TypeText("pass");
browser.Button(Find.ByName("SUBMIT")).Click();https://stackoverflow.com/questions/2857040
复制相似问题