【发布时间】:2011-03-11 16:11:55
【问题描述】:
我正在尝试使用 TestDriven.Net 让 WatiN 在 VS2010 中使用 MSpec。我的代码如下:
[Subject("Whatever")]
public class when_on_home_page {
private static IE browser;
Establish context = () =>
browser = new IE();
Because of = () => {
browser.GoTo("http://localhost:1234/");
browser.WaitForComplete();
};
It should_show_add_details_link = () =>
browser.Link(Find.ByValue("Add Details")).Exists.ShouldBeTrue();
}
当我运行这个时,浏览器会加载页面,但是当它检查链接时,我得到:
无论如何,在主页上时
» 应该显示添加详细信息链接(失败)测试“应该显示添加详细信息链接”失败: System.UnauthorizedAccessException:访问被拒绝。 (来自 HRESULT 的异常:0x80070005 (E_ACCESSDENIED)) 在 mshtml.IHTMLElementCollection.tags(对象标签名) 在 WatiN.Core.Native.InternetExplorer.IEElementCollection.GetElementsByTag(String tagName) 在 WatiN.Core.NativeElementFinder.FindElementsByTag(String tagName) 在 WatiN.Core.NativeElementFinder.d__2.MoveNext() 在 WatiN.Core.ElementFinder.FindFirst() 在 WatiN.Core.Element.FindNativeElementInternal() 在 WatiN.Core.Element.get_Exists() NavigationSpecs.cs(20,0):在 RoboWeb.Specs.when_on_home_page.<.ctor>b__2() 在 Machine.Specifications.Model.Specification.InvokeSpecificationField() 在 Machine.Specifications.Model.Specification.Verify()
环顾四周,我检查了以下内容:
- VS 正在以管理员身份运行
- TestDriven.Net 显然在 STA 模式下运行一切
- IE 已关闭“保护模式”
- 我无法将该网站添加到受信任的网站,可能是因为它在本地运行
- 我调用了WaitForComplete(),也试过Thread.Sleep()
我也尝试过使用 FireFox,但它只是崩溃了。
知道我在这里做错了什么吗?
【问题讨论】:
标签: visual-studio-2010 c#-4.0 watin testdriven.net mspec