Ask a Question

What is the use of Aliases

Lagencie
Frequent Contributor

What is the use of Aliases

I just started with my Test Environment and already came across a few veryyyy bad problems using these aliases ...


Why should i use this aliases?


When i use the namemapping path it automatically corrects testcases in my project, when this namemapping changes...


On the other hand, if I used the alias it created for the namemapping and these get changed, it doesnt change the aliases used in testcases.


Right now i only have like 10 testcases - but when I have a big project where i use those aliases a couple of thousand times it would be like a destroyed project, just renaming 1 alias ...


In my case was the problem that 1 element (a panel) got added so I remapped the panel and dragged the objects onto this panel -> making the alias change for this instead of xxx.element it was than xxx.panel.element making all my testcases unrunable

4 REPLIES 4
Lagencie
Frequent Contributor

ADD:

 

Ok I just found out, that it actually adapts the keyword tests to changed aliases, but only half of the used objects.

 

on-screen action elements -> get changed to the new alias

 

Alias Values in if...then / Set Variable -> dont get changed

 

Is this a bug / incomplete feature?

tristaanogre
Esteemed Contributor

The purpose of Aliases is to translate what's in the NameMapping tree to something useful.  

 

So, let's say for example, in a web application, you have the following in NameMapping

 

NameMapping.Sys.browser.myPage.panel.panel.table.cell01.panel.panel.button

 

By default, TestComplete creates the Alias like so

 

Aliases.browser.myPage.panel.panel.table.cell01.panel.panel.button.

 

Obviously, this works just fine... but it's an awefully long string.  A lot of those "panel" designators are just DIV tags in your web page that you never interact with directly.  So, they kind of take up space in your automation and confuse things.  So, let's say you want the button to be referenced directly off the page.  You DO NOT change the NameMapping tree.  Instead, you drag "button" to be a direct child of myPage and delete the other Aliases (make sure, when doing so, when prompted you DO NOT delete the corresponding NameMapping items).  What you are left with then is

 

Aliases.browser.myPage.button

 

And you use that throughout your automation.

 

Now, say your developers change your application where they add new Div tags etc.  Technically, you don't need to change the Alias at all.  Simply go to the NameMapping and add the additional intervening objects as necessary.  Then TestComplete can still find the object and NONE OF YOUR CODE ever needs to change.

 

THAT'S what Aliases does for you... it provides a translation layer between NameMapping and your code so that you can identify your objects via Alias in your code and re-organize your NameMapping as necessary.

 

In our environment, as a Best Practice, we NEVER change an Alias if we can avoid it.  That way we don't "break" even those "if..then" or "Set Variable" options.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Lagencie
Frequent Contributor

is there a plan for the future to include all alias changes to change the used testcases too?

tristaanogre
Esteemed Contributor

As you noted, it's already updating a good chunk of where the Alias is being used in keyword tests.  There are few outliers out there but, again, the Best Practice is to avoid altering Aliases once they are in use.  There really is no need to for most development work because any adjustments to object identification can be handled through the NameMapping panel which is invisible to any test or code using an Alias.

 

if there is a specific improvement you want to see, you can submit a feature request for consideration.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
cancel
Showing results for 
Search instead for 
Did you mean: