Forum Discussion

Lagencie's avatar
Lagencie
Frequent Contributor
7 years ago

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

  • Lagencie's avatar
    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's avatar
      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.

      • Lagencie's avatar
        Lagencie
        Frequent Contributor

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