Forum Discussion

Wamboo's avatar
Wamboo
Community Hero
6 years ago

NameMapping Alias and find function

Hey, How to correctly search for elements in a project using Aliases from NameMapping as an anchor in the .find() function?   Using NameMapping I create only the application skeleton and elemen...
  • RUDOLF_BOTHMA's avatar
    6 years ago

    As a general rule of thumb, NameMapping is your friend.  It speeds up the find process, since TC caches it rather than having to traverse the hierarchy each time.  So if possible, use name mapping.  Stay away from Sys.process("myAPP") if you can.  Sometimes its unavoidable, but in the vast majority of cases, it can be replaced with aliases.

     

    Findxxx has it's place.  You will probably find that Waitxxx works in more instances.  In both cases, it would be good practice to follow with with an exists check.

     

    So, as to your questions:

    1. No.  The findxxx/find function works by taking a set of properties and values that can be anything.  It is when you don't know what it is called that you would use this. e.g. [thin air example] you are looking for a button with text on like item(s).  You don't know if your button will say Item or Items, so you can do a find with property [contentText] and value [Item*]

    2. Yes.  For testConplete there is no difference between a mapped name and something you got with a find.  Think of a mapped name like Aliases.impuls.frmimpulsMain...  as just a very long, global variable name with the value of an object. A find method returns the same object on which you can apply a find, which returns an object etc.  

     

    The takeaway:

     

    - If you can name map them, do so and make use of WaitAliasChild.  It's faster, cleaner and easier to maintain in the long run. 

    - If you can't name map them make use of WaitNNN methods

    - In both cases, make liberal use of the object.Exists property to check your Find or Wait methods successfully found you object and if .Exists is false, cleanly exit your method