Forum Discussion
Can you post the code? What code language are you using? A bit more information as to what this looks like will help out.
I am using Vb Script for scripting. Following is one of the sub which we are using
Sub TestSub(engName,Ftype)
If Sys.Process("*").WPFObject("HwndSource: DesignerHost").Exists Then
Sys.Process("*").WPFObject("HwndSource: DesignerHost").Close
End if
BuiltIn.Delay(4000)
If Sys.Process("eAudIT").WPFObject("HwndSource: eAudITMessageBox", "").Exists Then
Set msgBox = Sys.Process("eAudIT").WPFObject("HwndSource: eAudITMessageBox", "").FindChild(Array("Name","Visible"),Array("WPFObject(""btnYes"")", True),10)
If msgBox.Exists Then
Call msgBox.Click
End If
End If
Engagement="Engagement:"+engName
Builtin.Delay (2000)
End Sub
Here in the first If condition if the object does not exists, it will have the mentioned error in Err. Description and it will come out of the Sub without going to the remaining code. Please let me know if you require any further information.
- tristaanogre7 years agoEsteemed Contributor
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- AlexKaras7 years agoChampion Level 3
> A proper code for checking this condition would be
Sys.Process("*").WaitWPFObject("HwndSource: DesignerHost", -1).Exists
I think that it should be:
Sys.Process("*").WaitWPFObject("HwndSource: DesignerHost", 0).Exists
As per documentation, timeout that equals to -1 will wait forever, while if timeout is zero, than no wait will occur, just a check of whether or not the sought for object exists.
Everything else said by Robert is perfectly correct.
- sree20117 years agoContributor
Thank you for your suggestions
- sree20117 years agoContributor
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.