Forum Discussion

ackmondual's avatar
ackmondual
Contributor
4 years ago
Solved

Any pitfalls with making most of the aliases on the root level?

I'm testing an Android app.  I've been building out the Namemapping and Aliases.  I'm wondering if there's anything I should be aware of if I copy most of the objects onto the root level of the Alias section for easy access.  Otherwise, I typically have to drill down 7 to 11 levels deep just to get to them.

 

Off the top of my head, make sure all names are unique.  Else you get run time errors, or logic errors as TC references the wrong object.

  • Are you using keyword tests or scripting? If you're writing scripts you can assign your name mapping to variables, making that the new root.

    e.g. mainPage = Aliases.App.HwndSource_Window.Window.MainFrame.MainPage;

     

    You can do this for keyword tests by setting a project-wide variable and using that.

     

    I would think it's generally not a good idea to copy them to the root level, unless you can be sure they're all unique and they have unique identification properties. They're in a hierarchy for a reason 😉

3 Replies

  • tphillips's avatar
    tphillips
    Frequent Contributor

    Are you using keyword tests or scripting? If you're writing scripts you can assign your name mapping to variables, making that the new root.

    e.g. mainPage = Aliases.App.HwndSource_Window.Window.MainFrame.MainPage;

     

    You can do this for keyword tests by setting a project-wide variable and using that.

     

    I would think it's generally not a good idea to copy them to the root level, unless you can be sure they're all unique and they have unique identification properties. They're in a hierarchy for a reason 😉

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

     if there's anything I should be aware of

    Nothing that I can think of. (Obviously, given that aliased names are unique.) Actually, this is one of the purposes of Aliases: to make mapped objects' tree to be less deep and be more convenient for use in test code.