ComException coming from White

Aug 1, 2008 at 11:56 AM
Edited Aug 20, 2008 at 10:36 AM
We're frequently getting the following error coming out of White; I've traced it down to checking the IsClosed property on a Window which essenitally uses the Current.isOffScreen property on an automation element.

Any suggestions why this might be happening?

Thanks,

James.

Bricks.BricksException : Error invoking ListBox.get_Items ----> System.Runtime.InteropServices.COMException : Exception from HRESULT: 0x80042002 TearDown : System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ----> System.Runtime.InteropServices.COMException : Exception from HRESULT: 0x80042002
 
Coordinator
Aug 5, 2008 at 2:34 PM
I tried search on internet about it and seems like WMI issue. Not sure what this has to do with UIAutomation. I am putting this check in the IsClosed method.
Aug 20, 2008 at 10:40 AM
Edited Aug 20, 2008 at 10:44 AM
We think the COMExeptions are happening in cases where we try and check isClosed when the the automation element isnt in a state where its either closed or not, for example, when the automation element is still loading. We have got round this by wrapping the isClosed as in the following code snippet. What we are seeing that on the 2/3rd try the COMException is not thrown and isClosed returns succesfully allowing the test to continute.

Could you consider building this robustness into White?

Thanks

James.

 

Exception innerException = null
for (int tryNo = 0; tryNo < 3; tryNo++) 
{
try

return mMainWindow.IsClosed; 
}
catch (System.Runtime.InteropServices.COMException e)

 
Console.WriteLine("***************************************************************************"); 
Console.WriteLine("* COMException Occurred in Window.Get_IsClosed on attempt " + tryNo + " *"); 
Console.WriteLine("e.ToString Returns: " + e.ToString());
PrintLocation();
Console.WriteLine("***************************************************************************");
innerException = e;
}
}
try 
{
Console.WriteLine("***************************************************************************");
Console.WriteLine("i2.Window.Get_IsClosed failed multiple attempts. Dumping mMainWindow Properties:");
string mainWindowTitle = mMainWindow.Title;
Console.WriteLine("Title:" + mainWindowTitle);  
Console.WriteLine("Automation Element:" + mMainWindow.AutomationElement);
Console.WriteLine("***************************************************************************");
}
catch (Exception dumpException)
{
 
Console.WriteLine("Failed to dump properties" + dumpException.ToString());
}
throw new WindowIsClosedFailingException("i2WindowIsClosed has failed", innerException);
public class i2WindowIsClosedFailingException : Exception
{
public WindowIsClosedFailingException(string message, Exception innerException) : base(message, innerException)
{
}
}