【发布时间】:2015-09-08 10:24:43
【问题描述】:
由于 Internet Explorer 忙时超时错误,我的一些测试似乎随机失败。
WatiN.Core.Exceptions.TimeoutException: Timeout while Internet Explorer busy
他们的错误似乎只在以下代码行引起:
WatiN.Core.Browser.AttachTo[T](Constraint constraint)
我的设置方法:
[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 是类级别的全局变量:
IE _browser;
然后在测试中,我在打开的窗口上执行了一些操作,其中一个操作是单击一个按钮,该按钮会在应用程序中打开一个新选项卡。 然后为了获得对这个新页面的引用,我使用以下行:
Thread.Sleep(6000); //even sleeping but to no avail
Browser workItem = Browser.AttachTo<IE>(Find.ByTitle(new Regex(workItemRegex)));
这似乎会随机抛出错误,有时会起作用,有时会出错。
我不太确定这里出了什么问题,因为这似乎是合乎逻辑的。
在测试的 TearDown 中,所有 IE 进程都被杀死,_browser 被设置为 null。
有什么想法吗?
【问题讨论】: