I have a if statement that checkes whether an object exists, if the object_A exists then set it as a wrapper, if object_A doesn't exist, then Object_B will exist for sure, so then set object_B as the wrapper. But when object_A doesn't exist, TC keeps waiting, until the default wait time runs out. Is that how it works? Is there any method I can use to check and switch to object_B if A is not found without waiting? Both object_A and B are mapped.
If Object_A.Exists Then
set wrapper = Object_A
set wrapper = Object_B
I also tried namemapped the parent of the object that I want to check, then I do If Object_Parent.WaitAliasChild("Target_Object",0) Then xxxx, but it returns the parent object doesn't have a child with the target object name.
Thanks @RUDOLF_BOTHMA@Marsha_R , I ended up using Object_A_Parent.WaitChild(Object_A,0).Exists, whenever I used WaitAliasChild, it always returned me the parent object doesn't have a child with Object_A.
Also can WaitChild check grandchild object or even deeper? Looks like it can only check the child object 1 level under it.
No, WaitChild and WaitAliasChild is limited to the single child tier. Same goes for all the WaitNNN methods. If you need to traverse multiple tiers and you don't know the structure - or it's unreliable - you will have to use Find methods (FindChild, FindChildEx, FindAll). The winner would be if you can reliably Map & Alias them, since it's faster, but sometimes Find methods are unavoidable. Find methods can also accept a timeout as parameter, so you can make this short as well. It will return early the moment it finds the object though, so you can afford to not make it TOO short and not allow TC to find it. The more specific you can be with your property values for your find, the better, so try and get those ientification details as specific as possible.
Seperate thought. You may just be going too fast for TC to keep up. That is where Wait is better than Find. You can however, in web applications, also be running into AJAX issues. TC caches the mappings, so when AJAX changes the web page, TC doesn't always know - it has the old page layout cached or doesn't know about the child yet. In this case, consider using Refreshmapping/RefreshMappingInfo() on the parent object before trying to find the child
------------------------------------------------- Standard syntax disclaimers apply Regards,