A WatiN step that runs as part of a continuous integration build process is failing while attempting to attach to a browser instance intermittently. Currently about 1 in 5 times.
Browser.AttachTo<IE>(Find.ByTitle("Title of Popup"));
With the following error:
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)
I've done all the obvious things which have been suggested in previous posts:
I.e. Kill all internet explorer processes before running a WatiN step:
Process.GetProcessesByName("IEXPLORE").ToList().ForEach(p => p.Kill());
Increase the timeouts before running any WatiN steps:
var timeout = 60;
Settings.AttachToBrowserTimeOut = timeout;
Settings.WaitForCompleteTimeOut = timeout;
Settings.WaitUntilExistsTimeOut = timeout;
Each WatiN step is passed in as an action in the following code block:
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();
}
}
Does anyone know of something else I can do/check to get to the bottom of this annoying error message?
I have had similar problems in the past, and the solution was to simply reuse the same browser window, per session. Create a browser window when the first test executes and use it for all tests, then optionally close it when the test session ends. Obviously, this is dependent on what test harness you're using, but it should work. Creating and destroying IE windows is a resource-intensive activity so it's best to avoid it, if possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With