alinder
14 years agoContributor
WaitAliasChild failure returns exception, not a stub object.
My TestComplete project has connections to some external systems. We want to be able to select objects based on some partial information about the mapped alias: the alias name of the specific object and the alias name of one of its ancestors.
Example:
The object Aliases.Alpha.Beta.Delta.Epsilon can be identified by the external system as (Beta, Epsilon), or (Delta, Epsilon).
The initial approach was to use FindChild twice, using the MappedName property, but we are finding this gives very poor performance, between 4 to 8 seconds to return every object. This doesn't scale to our needs well.
WaitAliasChild appears to return results much faster, so seems preferable when applicable (as in when finding object Epsilon from object Delta).
The problem I encountered is that if the value of parameter ChildName is not mapped in the Aliases tree as a child of TestObj, an exception is raised instead of the Result returning the empty stub object that indicates the failure.
For example, if object Aliases.Alpha.Beta.Delta.Epsilon is displayed on screen, the command Aliases.Alpha.WaitAliasChild(Delta,0) generates an exception.
The normal case (Aliases.Alpha.WaitAliasChild(Beta,0)) works as expected.
I also believe normal failure case (Aliases.Alpha.WaitAliasChild(Beta,0) when Beta does not currently exist in the tested app) properly returns the stub object.
My solution has been to check with IsSupported before calling WaitAliasChild, and if not, use FindChild, like this:
Example:
The object Aliases.Alpha.Beta.Delta.Epsilon can be identified by the external system as (Beta, Epsilon), or (Delta, Epsilon).
The initial approach was to use FindChild twice, using the MappedName property, but we are finding this gives very poor performance, between 4 to 8 seconds to return every object. This doesn't scale to our needs well.
WaitAliasChild appears to return results much faster, so seems preferable when applicable (as in when finding object Epsilon from object Delta).
The problem I encountered is that if the value of parameter ChildName is not mapped in the Aliases tree as a child of TestObj, an exception is raised instead of the Result returning the empty stub object that indicates the failure.
For example, if object Aliases.Alpha.Beta.Delta.Epsilon is displayed on screen, the command Aliases.Alpha.WaitAliasChild(Delta,0) generates an exception.
The normal case (Aliases.Alpha.WaitAliasChild(Beta,0)) works as expected.
I also believe normal failure case (Aliases.Alpha.WaitAliasChild(Beta,0) when Beta does not currently exist in the tested app) properly returns the stub object.
My solution has been to check with IsSupported before calling WaitAliasChild, and if not, use FindChild, like this:
If aqObject.IsSupported(Aliases.Alpha,Epsilon) Then
Set obj1 = Aliases.Alpha.WaitAliasChild(Epsilon,0)
If obj1.Exists = False Then
Set obj1 = NameMapping.Sys.FindChild("MappedName","Aliases*" & Epsilon,100,True)
End If
Else
Set obj1 = NameMapping.Sys.FindChild("MappedName","Aliases*" & Epsilon,100,True)
End If