Placing NameMapping data into vars
- 6 years ago
Hi automTest
I have used a similar approach previously and can say that I won't recommend it. For example, I was storing a combobox in a variable because I was applying lots of operations on the same object. Inevitably though, somewhere through the test run, the handle to the object would be destroyed and you would get an error about not being able to find the object despite it obviously being on the page. You don't even need a page load for the mapping to change in some cases. This means that each time you want to work with the object - before Click(), HoverMouse() and VisibleOnScreen() - in your example, you first have to check that it exists AND remap it if it doesn't. If you keep it local to your script, you may still need to do the same, but you will find you don't need to refresh the mapping info as often, which means less of a performance hit, which will slow down your tests. Taking longer to type your code is better than taking longer to run your scripts. You will make up the difference after a few test runs.
What I could suggest to make the typing easier. You can assign the aliases object to a variable inside your script. You don't need to store it in a global variable, but you don't need to type as much either:
var myLabel = Aliases.MyApp.Panel1.Panel0.Panel2.Table.Cell1.Label; myLabel.Click(); myLabel.HoverMouse(); myLabel.VisibleOnScreen();
You only had to use that long Aliases... syntax once in the entire script. Slightly more typing than a global variable, lots less failed tests because of object recognition issues totally unrelated to what you are actually trying to test