通过 MbUnit 使用 WatiN 测试 ASP .Net MVC Web 应用程序
我正在尝试将一些 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 locahost 上测试网站应该没有显着差异。
两个可能的原因:
如果您的网页包含任何重要的 AJAX,则该页面可能永远不会完全加载,因此 WatiN 会一直等待。
如果您的网页包含任何
我现在修复了 WatiN 中的一两个错误,这些错误与检测页面已完全加载有关。您可以尝试获取 WatiN 主干源并构建最新代码的新副本。
如果这些都没有帮助,WatiN 还提供了多种操作的“NoWait”变体,例如单击。您还可以通过注册 WaitForComplete 处理程序来覆盖 WatiN 等待页面完成的含义。
There should be no significant differences testing a website on locahost.
Two possible causes:
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.
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.
当我引用未加载的资源时,我就遇到过这种情况。
I've had this happen to me when I had a reference to a resource that didn't load.
确保该程序以管理员身份运行。在 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.