通过 MbUnit 使用 WatiN 测试 ASP .Net MVC Web 应用程序

发布于 2024-08-11 00:15:53 字数 1735 浏览 2 评论 0原文

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

如果我完全按照此页面上的说明进行操作,那么谷歌主页就会​​加载,文本已插入,搜索已完成并且测试通过。 (这里没问题)。

但是,当我简单地将行的 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

还有其他人收到此消息,还是只有我收到此消息?

I am trying to apply some WatiN UI tests to my new ASP .Net MVC application, running the WatiN tests through MbUnit, but am having some difficulties.

If I follow the instructions (exactly) on this page, then the google homepage loads, up the text is inserted, the search is done and the test passes. (no problem here).

However, when I simply change the URL of the line...

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

to the website hosted on my PC through IIS (on Win7), (e.g. to http://localhost/myapp/) the homepage of my application loads fine, but the test-runner seems to still be waiting for confirmation that the page has loaded and then the test fails due to a timeout.

Here's the failed response from within the 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

Anybody else get this, or is it just me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

池木 2024-08-18 00:15:53

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

两个可能的原因:

  1. 如果您的网页包含任何重要的 AJAX,则该页面可能永远不会完全加载,因此 WatiN 会一直等待。

    如果您的网页包含任何

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

如果这些都没有帮助,WatiN 还提供了多种操作的“NoWait”变体,例如单击。您还可以通过注册 WaitForComplete 处理程序来覆盖 WatiN 等待页面完成的含义。

There should be no significant differences testing a website on locahost.

Two possible causes:

  1. If your webpage contains any significant AJAX then it's possible that the page never appears to be fully loaded so WatiN just keeps waiting.

  2. I have fixed one or two bugs in WatiN now and then related to detecting that a page has been fully loaded. You might try grabbing the WatiN trunk source and building a fresh copy of the latest code.

If none of that helps, WatiN also has "NoWait" variants of several actions like clicking. You can also override what it means to WatiN to wait for a page to be complete by registering a WaitForComplete handler.

像极了他 2024-08-18 00:15:53

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

  • 是否引用了不存在的 JS、CSS 或图像文件?
  • 如果您使用 Fiddler 查看 HTTP 流量,您是否看到任何连接超时?

I've had this happen to me when I had a reference to a resource that didn't load.

  • Do have a reference to a JS, CSS, or image file that doesn't exist?
  • If you look at the HTTP traffic with Fiddler do you see any connections timing out?
淡水深流 2024-08-18 00:15:53

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

Make sure the program is running as an administrator. On Win7 it will load the page but Watin can't access the DOM unless Visual Studio or Gallio Icarus are started with administrator privileges.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文