I have a number of tests that seem to be randomly failing due to a Timeout while Internet Explorer busy error.
WatiN.Core.Exceptions.TimeoutException: Timeout while Internet Explorer busy
They errors seem to be only caused on lines with code of:
WatiN.Core.Browser.AttachTo[T](Constraint constraint)
My setup method:
[SetUp]
[Timeout(1000)]
public void WithAnInstanceOfTheBrowser()
{
Settings.AttachToBrowserTimeOut = 200;
Settings.WaitUntilExistsTimeOut = 200;
Settings.WaitForCompleteTimeOut = 200;
Settings.SleepTime = 60;
BrowserExtension.KillAllIEProcess();
var securePassword = new SecureString();
foreach (var c in UserConfig.GetConfigPassword())
{
securePassword.AppendChar(c);
}
string address = UserConfig.GetConfigUrl();
string username = UserConfig.GetConfigUserName();
ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\Program Files\Internet Explorer\iexplore.exe", address);
startInfo.UserName = username;
startInfo.Password = securePassword;
startInfo.UseShellExecute = false;
startInfo.LoadUserProfile = true;
Process.Start(startInfo);
_browser = Browser.AttachTo<IE>(Find.ByUrl(UserConfig.GetConfigUrl()));
}
_browser is a global variable at the class level:
IE _browser;
Then in the test I perform a number of actions on the window that opens up and one of these actions is clicking a button and this button opens a new tab within the application. Then to get a reference to this new page I use the lines:
Thread.Sleep(6000); //even sleeping but to no avail
Browser workItem = Browser.AttachTo<IE>(Find.ByTitle(new Regex(workItemRegex)));
This seems to throw back errors randomly, Sometimes it works and sometimes I get an error.
I'm not exactly sure whats going wrong here because it seems logical that this should work.
In the TearDown of the test all IE processes are killed and _browser is set to null.
Any Ideas?