Get raw Alias from sub object

Originally posted by mdehaan on July 30, 2025

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.SearchFieldAs 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!

Originally posted by rraghvani on July 30, 2025

A Stub object is like an “empty” object with minimal properties/methods, just enough to simulate the real object’s behaviour. It may not have the mapped name - you can verify this via debugging and viewing the actual contents of the Object.

Originally posted by mdehaan on July 30, 2025

Yeah, that’s correct. The stub object only has the .Exists property. Still, somewhere in the system should be a reference to the Alias (Aliases.Application.SearchField in this case) cause how else would the system know this particular object does not exist. And how is it listed in the Unable to find the following objectlogging? And I’m wondering what I need to do to find it. In essence I just want to know which Alias I’m processing

Originally posted by rraghvani on July 30, 2025

I suggest you read through Object Browser and you will get a better understanding of how TestComplete goes about identifying objects.

Originally posted by Hassan_Ballan on July 30, 2025

I don’t claim that I am grasping the conversation or the framework you are building. When I started working with TestComplete I first focused on learning how it was intended to be used going thru its features for strength and weaknesses. After that I built a unique framework described in https://smartbear.com/blog/pro-tips-from-the-smartbear-community-scaling-salesforce-testing-with-testcomplete/

One thing for sure you must wait for the object before retrieving mapping info. Always call .WaitProperty(“Exists”, true, timeout) on the alias first—otherwise the child may not yet be registered in the mapping table. Than use WaitAliasChild before interacting with a child object.

:speech_balloon: Found the answer helpful? Give it a Like!
:white_check_mark: Got your issue resolved? Mark it as the solution so others can find it fast.

Originally posted by scot1967 on July 31, 2025

Hello mdehaan,

TestObj.WaitAliasChild(ChildName, WaitTime)

If TestObj exists it will contain a path you can return and use as a string and then concatenate ChildName to produce the path you are looking for. The stub object can’t contain the path to something it can’t find but you can log what you asked it to find. Am I over simplifying the issue (missing something)? Let me know. :wink:

var parent = Aliases.App;
var childName = "MainWindow";

var child = parent.WaitAliasChild(childName, 5000);

if (!child.Exists) {
  Log.Warning("Object not found. Attempted alias path: " + parent.FullName + "." + childName);
} else {
  Log.Message("Object found: " + child.FullName);
}

I hope this helps!

… If you find my posts helpful drop me a like! :+1: Be sure to mark or post the solution to help others out and/or to credit the one who helped you. :smiling_face_with_sunglasses:

Originally posted by mdehaan on August 01, 2025

Well, the thing is that the function I’m using gets the Alias as a parameter. Therefore I don’t know the parent without calling Alias.Parent. Neither do I know childName for the same reason. I want to pick it from the Alias using Alias.MappedName but I need for the object to Exists before I can do that. And in order to use parent.WaitAliasChild(childName) I need the MappedName. Thus I’m running in circles. If I could get the MappedName from the stub object (which is based on an Alias being exactly what I need) then I could identify the Parent and childName.
I think the stub object should contain *{Exists: false, MappedName: Aliases.Application.SearchField, FullName: Sys.ApplicationName.Yada.Yada.Yada.SearchField}*A little code example of the problem: *test(Aliases.Application.Screen1.SearchField)
test(Aliases.Application.Screen2.SearchField)

function test (Alias) {
Aliases.Application.???.WaitAliasChild(‘SearcField’)
}*

Originally posted by mdehaan on August 01, 2025

But isn’t that odd? Since the framework uses the Alias and FullName to check if the object exists in the first place.

I think the stub object should contain
*{
Exists: false,
MappedName: Aliases.Application.SearchField,
FullName: Sys.ApplicationName.Yada.Yada.Yada.SearchField
}*Or there should be some other way to fetch the pointer from an Alias-defined non-existent object.

A little code example of the problem: *test(Aliases.Application.Screen1.SearchField)
test(Aliases.Application.Screen2.SearchField)

function test (Alias) {
Aliases.Application.???.WaitAliasChild(‘SearcField’)
}*

How do I identify the Parent? Assuming there can be many input Aliases in this function

Originally posted by rraghvani on August 01, 2025

Based on your example code - as an example, you can do this

function test()
{
    // Assuming Aliases.Application.Screen1/2 object exists.
    search(Aliases.Application.Screen1);
    search(Aliases.Application.Screen2);
}

function search(obj)
{
    // Use the WaitAliasChild method to delay the test execution until the object specified 
    // by its alias appears in the system or until the specified time limit is reached
    if (obj.WaitAliasChild("SearchField", 30000).Exists) {
        Log.Message("Found child 'SearchField'.")
    } else {
        Log.Warning("Did not find child 'SearchField' within the specified time period.")
    }
}

The parent object is Aliases.Application.Screen1, and you are waiting for the child object SearchField to appear within the 30 second time period.

Originally posted by scot1967 on August 01, 2025

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

Originally posted by Hassan_Ballan on August 01, 2025

TestComplete does not provide a built-in way to retrieve the .MappedName or full alias path from a stub object. Stub objects are placeholders created by TestComplete (for example, via Utils.CreateStubObject() or when using methods like WaitAliasChild() before the actual UI element exists). These stub objects only expose limited properties—primarily .Exists—and any attempt to access other properties or methods like .MappedName will raise exceptions, since the underlying UI object is not available yet.

To keep your logic dynamic and avoid needing .MappedName from a stub, a reliable workaround is to use string paths instead of alias objects. For example, pass the alias path as a string (e.g., “Application.Screen1.SearchField”) into your function, then dynamically resolve it by splitting the string and calling WaitAliasChild() step-by-step, like this:

function waitForAliasPath(aliasPathStr) {
  var parts = aliasPathStr.split('.');
  var current = Aliases;
  for (var i = 0; i < parts.length; i++) {
    current = current.WaitAliasChild(parts[i], 10000); // waits up to 10 seconds for each part
  }
  return current;
}

// Usage
var searchField = waitForAliasPath("Application.Screen1.SearchField");

This approach avoids direct dependency on .MappedName and works consistently even when the UI object is not yet rendered.

Note: While this method is effective, it breaks direct ties to the Aliases tree in your code, so you lose IntelliSense/auto-complete support and increase the risk of typos. Also, be aware that using string-based dynamic evaluation requires careful handling to avoid maintenance or security issues.

Lastly, attempts to extract alias paths from error messages (such as those thrown by aqObject.CheckProperty) are considered fragile hacks and are not recommended for production code.

:robot: AI-assisted response referencing https://support.smartbear.com/testcomplete/docs/

:speech_balloon: Found the answer helpful? Give it a Kudos by clicking Like!
:white_check_mark: Got your issue resolved? Click Mark as Solution so others can find it quickly.

Originally posted by mdehaan on September 19, 2025

I submitted the Feature Request: https://community.smartbear.com/idea/testxcompletefeaturerequests/access-alias-path-information-from-stub-objects-in-testcomplete/278191