我正在尝试使用 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))在 WatiN.Core.Native.InternetExplorer.IEElementCollection.GetElementsByTag(String tagName) 的 WatiN.Core.NativeElementFinder.FindElementsByTag(String tagName) 的 mshtml.IHTMLElementCollection.tags(Object tagName) .Core.NativeElementFinder.d__2.MoveNext() at WatiN.Core.ElementFinder.FindFirst() at WatiN.Core.Element.FindNativeElementInternal() at WatiN.Core.Element.get_Exists() NavigationSpecs.cs(20,0): at 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 尝试过,但它只是崩溃了。
知道我在这里做错了什么吗?