Forum Discussion
Actually, this line of code is problematic...
Sys.Process("*").WPFObject("HwndSource: DesignerHost").Exists
If the object does not exist... how can you check the "Exists" property of a non-existent object? This is improper code. In the recent versions of TC, this is being enforced a bit more strictly. A proper code for checking this condition would be
Sys.Process("*").WaitWPFObject("HwndSource: DesignerHost", -1).Exists
The WaitWPFObject method will wait for the object to resolve... if it doesn't within the designated time out, it returns a "stub" object with an Exists property set to false. This is the best practice for checking for object existance, using a "WaitNNN" method.
See
https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/window-and-process/waitwpfobject-method.html
Thank you for your immediate reply and providing a solution. These were legacy scripts which were developed from Test Complete 8 version onwards and were upgraded upto Test Complete 12.31. So the same type of code is used in many places and we will have lot of rework on the existing code. Is there any other work around for the same. Please advice.
- tristaanogre7 years agoEsteemed Contributor
Unfortunately, there's not really an easy work around. Checking for object existance has been well documented from a very early time in TestComplete (I've used versions all the way back to version 1.52) and starting at least with version 2 or 3 the idea of these "WaitNNN" methods has been around.
If you think about it logically, if an object does not exist, if it is not present, you cannot check the "Exists" property of it... because there is no object to have such a property.
- sree20117 years agoContributor
Thank you for your reply.