作为持续集成构建过程的一部分运行的 WatiN 步骤在尝试间歇性地附加到浏览器实例时失败。目前约为五分之一。
Browser.AttachTo<IE>(Find.ByTitle("Title of Popup"));
出现以下错误:
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.IEWaitForComplete.WaitUntilNotNull(DoFunc`1 func, BuildTimeOutExceptionMessage exceptionMessage)
at WatiN.Core.Native.InternetExplorer.IEWaitForComplete.WaitWhileIEBusy(IWebBrowser2 ie)
at WatiN.Core.Native.InternetExplorer.IEWaitForComplete.WaitForCompleteOrTimeout()
at WatiN.Core.WaitForCompleteBase.DoWait()
at WatiN.Core.Native.InternetExplorer.AttachToIeHelper.FinishInitializationAndWaitForComplete(IE ie, SimpleTimer timer, Boolean waitForComplete)
at WatiN.Core.Native.InternetExplorer.AttachToIeHelper.Find(Constraint findBy, Int32 timeout, Boolean waitForComplete)
at WatiN.Core.Browser.AttachTo[T](Constraint constraint)
我已经完成了之前帖子中建议的所有显而易见的事情:
即在运行 WatiN 步骤之前杀死所有 Internet Explorer 进程:
Process.GetProcessesByName("IEXPLORE").ToList().ForEach(p => p.Kill());
在运行任何 WatiN 步骤之前增加超时:
var timeout = 60;
Settings.AttachToBrowserTimeOut = timeout;
Settings.WaitForCompleteTimeOut = timeout;
Settings.WaitUntilExistsTimeOut = timeout;
每个 WatiN 步骤都作为以下代码块中的操作传入:
public void UseAndCloseBrowser(Action<Browser> action, Browser browser)
{
try
{
action(browser);
browser.WaitForComplete();
}
finally
{
Log(Level.Info, "Attempting to close browser {0}", browser.Title);
browser.Close();
browser.Dispose();
}
}
有谁知道我可以做些什么/检查以了解这个烦人的错误消息的底部?