Un passaggio WatiN eseguito come parte di un processo di integrazione continua non riesce mentre si tenta di collegarsi a un'istanza del browser in modo intermittente. Attualmente circa 1 su 5 volte.Browser.AttachTo <T>() causa un'eccezione intermittente "Timeout mentre Internet Explorer è occupato"
Browser.AttachTo<IE>(Find.ByTitle("Title of Popup"));
con il seguente errore:
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)
Ho fatto tutte le cose ovvie che sono state suggerite nel post precedente:
vale a dire Uccidere tutti i processi di Internet Explorer prima di eseguire un passo WatiN:
Process.GetProcessesByName("IEXPLORE").ToList().ForEach(p => p.Kill());
incrementare i timeout prima di eseguire qualsiasi iniziativa Watin:
var timeout = 60;
Settings.AttachToBrowserTimeOut = timeout;
Settings.WaitForCompleteTimeOut = timeout;
Settings.WaitUntilExistsTimeOut = timeout;
Ogni passo WatiN viene passato come un'azione nel seguente blocco di codice:
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();
}
}
Qualcuno sa di qualcos'altro che posso fare/controllare per arrivare in fondo a questo fastidioso messaggio di errore?
Qual è il contesto in cui è in esecuzione WatiN? Ad esempio, è in esecuzione all'interno di un servizio Windows CruiseControl.NET? Ho avuto molti problemi con WatiN in esecuzione da servizi Windows perché i servizi Windows sono applicazioni senza finestre. – NathanAldenSr
Ciao, scusa non ti ho risposto prima .. È l'agente è un servizio di Windows ed è in esecuzione usando il mio nome utente. Così ha pieno accesso a Internet Explorer ecc. Tutto funziona tranne l'attach, che come ho detto sta fallendo a intermittenza. – CraftyFella