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.
🤖 AI-assisted response referencing https://support.smartbear.com/testcomplete/docs/
đź’¬ Found the answer helpful? Give it a Kudos by clicking Like!
âś… Got your issue resolved? Click Mark as Solution so others can find it quickly.