eccramer
14 years agoNew Contributor
WaitWinFormsObject not reliably detecting objects.
My team is testing a .NET application, so the WaitWinFormsObject method is used quite frequently in our tests. However, the WaitWinFormsObject method has not been finding some objects reliably on the first try, and has to be invoked twice (no matter what timeout specified) to find a windows form object. This has been happening intermittently, where TestComplete can see the object in the object browser, but WaitWinFormsObjet cannot resolve a handle to the object on the first invocation. It will however, find the object immediately if it is invoked again. For example:
//This will correctly find the process
var process = Sys.WaitProcess("OurApp", 1000);
//This will not find the WinFormsObject named FrameForm no longer how long the interval is.
var FrameFormHandle = process.WaitWinFormsObject("FrameForm", 36000);
However, if we invoke it this way:
//This will correctly find the process
var process = Sys.WaitProcess("OurApp", 1000);
//This will not find the WinFormsObject named FrameForm no longer how long or short the interval is.
var FrameFormHandle = process.WaitWinFormsObject("FrameForm", 1000);
if(!FrameFormHandle.Exists) {
//This WILL find the WinFormsObject named FrameForm IMMEDIATELY
FrameFormHandle = process.WaitWinFormsObject("FrameForm", 1000);
}
I've verified that the FrameForm object exists in the object browser before invoking WaitWinFormsObject, so this is not a race condition situation where the object does not exist when the method is first invoked. And again, this is intermittent issue, where sometimes TestComplete WILL correctly find the FrameForm object on the first try. There is no apparent reason for TestComplete not to find the object when first invoked, and I would prefer not to have to call WaitWinFormsObject twice. Sometimes it works as it's supposed to, and sometimes it doesn't. It almost seems like it fails to find the object on the first try more often than it correctly finds it.
Is there an issue in the way we're invoking the WaitWinFormsObject method, or is this an issue with the method itself, or is it some other issue.
//This will correctly find the process
var process = Sys.WaitProcess("OurApp", 1000);
//This will not find the WinFormsObject named FrameForm no longer how long the interval is.
var FrameFormHandle = process.WaitWinFormsObject("FrameForm", 36000);
However, if we invoke it this way:
//This will correctly find the process
var process = Sys.WaitProcess("OurApp", 1000);
//This will not find the WinFormsObject named FrameForm no longer how long or short the interval is.
var FrameFormHandle = process.WaitWinFormsObject("FrameForm", 1000);
if(!FrameFormHandle.Exists) {
//This WILL find the WinFormsObject named FrameForm IMMEDIATELY
FrameFormHandle = process.WaitWinFormsObject("FrameForm", 1000);
}
I've verified that the FrameForm object exists in the object browser before invoking WaitWinFormsObject, so this is not a race condition situation where the object does not exist when the method is first invoked. And again, this is intermittent issue, where sometimes TestComplete WILL correctly find the FrameForm object on the first try. There is no apparent reason for TestComplete not to find the object when first invoked, and I would prefer not to have to call WaitWinFormsObject twice. Sometimes it works as it's supposed to, and sometimes it doesn't. It almost seems like it fails to find the object on the first try more often than it correctly finds it.
Is there an issue in the way we're invoking the WaitWinFormsObject method, or is this an issue with the method itself, or is it some other issue.