Get raw Alias from sub object
Hi there,
I've been using TestComplete (primarily Javascript) for over a year now but I never managed to figure out how to get the raw Alias value from a stub object.
The context:
I have a generic search field object with the following Alias: Aliases.Application.SearchField
As it takes a while for the field to render I want to use WaitAliasChild to wait for the search field to appear. However the function processing the search field can also be applied to a different screen where the search field is defined as Aliases.Application.Screen1.SearchField. There are a dozen more similar Aliasses pointing to SearchFields I want to process with the same function. Therefore I'm passing the target Alias as a parameter to the function.
Ideally I would want to use the Alias parameter and call .MappedName. Then snip up the string into smaller bits and call WaitAliasChild for each snippet. For example calling the function with an Alias of Aliases.Application.Screen1.SearchField would then result in Aliases.Application.WaitAliasChild('Screen1').WaitAliasChild('SearchField'). Perfect!
However, since the object is not yet on screen the Alias parameter only carries a stub object. Alias.MappedName does not work as stubs only contain the .Exists parameter.
So my question is: is there a way to get the MappedName parameter from a stub object?
The oddest thing is that calling aqObject.CheckProperty on the Alias will throw an error which contains the actual MappedName. So I'm sure it is accessible somehow:
Unable to find the following object when executing the aqObject.CheckProperty command:
Aliases.Application.SearchField
I have been thinking about listing all Aliases as strings in the codebase and evaluating them when needed as objects but this will sever all ties to the actual Aliases library and is much more prone to typo's.
I hope someone can help, thanks!
Hello mdehaan,
This would be a new feature. Have you dropped an idea in the Feature Requests forum? If you don't think there is a way to do this other than through the returned stub object this would be the best action. You could also reach out to support.
Feature Request:
TestComplete Feature Requests | SmartBear Community
Support:
https://support.smartbear.com/testcomplete/message/
I hope you find an answer to this soon! Don't forget to mark a best answer to complete this issue when you think you have one and drop a few likes for the comments. We would really appreciate it!
Have a great day!
Scott