NameMapping Alias and find function
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 elements such as buttons and drop-down lists I want to search with .findxxx(); using the value from the previously mapped element in NameMapping -> Alias
1) Does the "check-in" (pointing with arrow on screen) button have to be mapped to NameMapping in order to search for it with .findxxx();?
2) in the function .findxxx() it is possible to use the previously mapped element as anchor, that is:
or Should I do it like this?:
Can you please show me some examples?
Whats the correct way?
Solved! Go to Solution.
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.
- 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
Standard syntax disclaimers apply