1

我正在尝试将一些 WatiN UI 测试应用于我的新 ASP .Net MVC 应用程序,通过 MbUnit 运行 WatiN 测试,但遇到了一些困难。

如果我按照此页面上的说明(完全正确),则加载 google 主页,插入文本,完成搜索并通过测试。(这里没问题)。

但是,当我只是更改该行的 URL 时...

var ie = new IE(new Uri("http://www.google.co.uk"));

通过 IIS(在 Win7 上)到我的 PC 上托管的网站,(例如http://localhost/myapp/)我的应用程序的主页加载正常,但测试运行程序似乎仍在等待确认页面已加载,然后测试失败由于超时。

这是来自 IDE 内部的失败响应...

*** Failures ***
Exception
WatiN.Core.Exceptions.TimeoutException: Timeout while Internet Explorer state not complete
   at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.ThrowTimeOutException(Exception lastException, String message)
   at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.HandleTimeOut()
   at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.Try[T](DoFunc`1 func)
   at WatiN.Core.WaitForCompleteBase.WaitUntil(DoFunc`1 waitWhile, BuildTimeOutExceptionMessage exceptionMessage)
   at WatiN.Core.Native.InternetExplorer.WaitForComplete.WaitWhileIEReadyStateNotComplete(IWebBrowser2 ie)
   at WatiN.Core.Native.InternetExplorer.IEWaitForComplete.DoWait()
   at WatiN.Core.DomContainer.WaitForComplete(IWait waitForComplete)
   at WatiN.Core.IE.WaitForComplete(Int32 waitForCompleteTimeOut)
   at WatiN.Core.DomContainer.WaitForComplete()
   at WatiN.Core.Browser.GoTo(Uri url)
   at WatiN.Core.IE.FinishInitialization(Uri uri)
   at WatiN.Core.IE.CreateNewIEAndGoToUri(Uri uri, IDialogHandler logonDialogHandler, Boolean createInNewProcess)
   at WatiN.Core.IE..ctor(Uri uri)
   at FppRendersUI.Test.Program.DoSomething() in C:\Dev\MyCode.Test\Program.cs:line 18

其他人得到这个,还是只有我一个?

4

3 回答 3

3

在 locahost 上测试网站应该没有显着差异。

两个可能的原因:

  1. 如果您的网页包含任何重要的 AJAX,那么该页面可能从未完全加载,因此 WatiN 只是一直等待。

  2. 我不时修复了 WatiN 中的一两个错误,这些错误与检测页面已完​​全加载有关。您可以尝试获取 WatiN 主干源并构建最新代码的新副本。

如果这些都没有帮助,WatiN 也有几个动作的“NoWait”变体,比如点击。您还可以通过注册 WaitForComplete 处理程序来覆盖对 WatiN 等待页面完成的含义。

于 2009-11-08T07:29:53.110 回答
2

当我引用未加载的资源时,我遇到过这种情况。

  • 是否引用了不存在的 JS、CSS 或图像文件?
  • 如果您使用Fiddler查看 HTTP 流量,您是否看到任何连接超时?
于 2009-11-08T21:09:29.230 回答
0

确保程序以管理员身份运行。在 Win7 上,它将加载页面,但除非以管理员权限启动 Visual Studio 或 Gallio Icarus,否则 Watin 无法访问 DOM。

于 2010-01-27T23:17:56.423 回答