7

我们有一组 WATIN 测试,我们使用 CruiseControl 每小时运行一次。所有测试都在我们的本地机器上通过 - 但是当它们使用 CruiseControl 运行时,我们会遇到零星的失败。

我们使用命令行使用 CruiseControl。我们没有使用 CruiseControl 服务。我们使用的是 IE8。

在运行每个测试之前 - 我们使用 WATIN 关闭浏览器的所有实例,以确保每个测试完全隔离。

这是我们在抛出异常时看到的堆栈跟踪的示例:

Message: WatiN.Core.Exceptions.TimeoutException : Timeout while Internet Explorer busy 
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.WaitWhileIEBusy(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.Element.WaitForComplete()
at WatiN.Core.Element.Click()
at Symetra.Web.Core.AutomatedTesting.WatiNTests.CommonTests.LinkTest(Browser browser, String linkText, String message) in d:\Source\BuildArea\OSS\Symetra.Web.Core.AutomatedTesting\Symetra.Web.Core.AutomatedTesting.WatiNTests\Common\CommonTests.cs:line 63
at Symetra.Web.Core.AutomatedTesting.WatiNTests.CommonTests.LinkTest(Browser browser, String linkText) in d:\Source\BuildArea\OSS\Symetra.Web.Core.AutomatedTesting\Symetra.Web.Core.AutomatedTesting.WatiNTests\Common\CommonTests.cs:line 57
at Symetra.Web.Core.AutomatedTesting.WatiNTests.GlowTests.BreadCrumbFixture.testid1Test() in d:\Source\BuildArea\OSS\Symetra.Web.Core.AutomatedTesting\Symetra.Web.Core.AutomatedTesting.WatiNTests\GlowTests\BreadCrumbFixture.cs:line 72

我们有什么措施可以防止这种情况发生吗?我尝试将 Thread.Sleep() 放在违规行的前面。这似乎没有效果。我一直非常小心地避免使用 Thread.Sleep()- 并使用 browser.WaitUntilContainsText。

我搜索了 StackOverflow 和 WATIN 用户电子邮件列表 - 似乎其他人也有类似的问题,但我没有看到任何解决方案。

4

2 回答 2

3

我们正在使用 Teamcity,但我们在 IE7 上遇到了类似的问题。问题的根源是打开IE。您已经提到您使用 Watin 关闭所有打开的实例。但请确保您使用 ie.ForceClose(); 在 TearDown 和 SetUp 中。

于 2009-08-03T09:51:52.660 回答
0

我对 WaitUntil 有同样的问题。但这只是因为该站点在服务器上不受信任,因此没有打开,所以我有时间。

也许你会遇到同样的问题......

于 2009-09-17T08:17:18.627 回答