Forum Discussion
14 Replies
Sort By
- jose_pitaSuper ContributorOK, now I see, you really took your time to study name mapping in order to use it the right way...
Congrats to you, I never had the patience to do it...
Ok, so now @Tez A just needs to pick wich one he likes the best :D
Nice discussion Colin ;) - Colin_McCraeCommunity HeroIndeed.
Object Identification is always an interesting subject if you're doing automation.
I made HUGE numbers of mistakes when setting up GUI maps in QTPro in the past. We thought about it and improved the way we did it. QTPro did not use Aliases, but did update all your scripts when you changed an object in the GUI map. Which was really helpful.
TC does not auto update object references in scripts. And Aliases were new to me when I started using it. But with a bit of experimentation, I *think* I've got a method that works well and allows for easy maintenance. It took a bit of trial and error, and figuring out best use of Aliases, but it seems to be working well now.
Fingers crossed! :) - jose_pitaSuper ContributorLeave name mapping and start using scripts to find the objects searching all the DOM elements.
Check out my gist on helper functions to see if it helps.
This is not smartbear's opinion, it is mine and mine alone, maybe someone with more experience on name mapping can give you a hand in order not to lose all the tests you have. - Colin_McCraeCommunity HeroUpdating the objects doesn't look like it would be too hard.
But updating all the scripts that use them might be.
To me, it looks like you have a lot of unnecessary layers in your alias objects? I use the Alias object to massively reduce the complexity of the object map. So if an intermediate layer changes, I can correct it and leave the lower level components alone in the Alias file. Correct the map file and the alias file sorts itself out.
Obviously, there are times where the Alias is also affected, but as long as your application is relatively stable, these should be minimal. They are for me.
I can't see what exactly your alias represents, but I would try and reduce the number of components it uses. Do you actually need all those intermediate components?
Jose - I know you and a few others on here use helper/search functions. If I'm working on something with a lot of dynamic components, I do the same. But in a non-dynamic site, are you not taking a big performance hit searching the whole DOM like that all the time?
Main point with name maps is not to bother with them until you are confident the site is relatively stable. Unfortunately, you do still have to take a hit occasionally. But with smart use of identification properties and aliases, you can really reduce the impact.
Updating all the alias references in the test scripts is far more of a problem. I've already seem someone ask for auto-updates to scripts when name map or alias changes happen. +1 to that from me! (QTPro does this from what I remember ...) - jose_pitaSuper ContributorI don't use name mapping or aliases anymore, losing all my work twice tought me a lesson or 2.... I don't understand when you say "But updating all the scripts that use them might be."... When I talk about scripts I leave everything name mapping related on the side...
If his application was stable, do you think he would be complaining about changes?
The time it takes to search for the object is minimal once you find the right parent and give it to the function. If it takes more than 1 second searching for the object from the page object, I just search for the most reliable parent and go from there, quite faster but not always needed.
I fully understand your point and as I said, it is just how I work, if you undestand name mapping there is probably a good way to work with it, I just couldn't find one that would fit my needs. - Colin_McCraeCommunity HeroI don't understand when you say "But updating all the scripts that use them might be."
The alias objects will be used in scripts. If you change the alias you also need to update the references to it in your script don't you?
And if you have a lot of scripts, that can be awkward. It is just a find and replace exercise usually, but with a lot of scripts that can still be time consuming.
I know what you mean about changes causing you re-work. I've been there myself. But by pre-mapping objects, I do find it's a lot faster. Especially when run on VM's running TestExecute which tend to be a lot lower powered than my development machine. But as long as the alias file contains ONLY the bare minimum, I also find that 90%+ of structural changes tend to be in the invisible container layers, which are not in the alias object references. Hence why I say fix the name map and the alias looks after itself.
And I've seen people start mapping way before it's appropriate to do so plenty of times. So I thought I'd ask the question on stability. :)
Using helper/search functions is an interesting approach. And I do make use of them myself. But in conjunction with a name map/alias file usually. Best of both worlds and all that. :) Name map on it's own would be horrible, and I suspect I would never use it. But the alias layer between the map file and your scripts is what makes it work for me.
If you use helper/search functions globally, do you not sometimes find you're in a position where you have to find and update multiple calls to it if the wrong thing changes? Leaving you in a similar position to name map/alias updates? - jose_pitaSuper Contributor"I don't understand when you say "But updating all the scripts that use them might be."
The alias objects will be used in scripts. If you change the alias you also need to update the references to it in your script don't you?"
I don't use alias objects, period. I only use helper functions, this way I just need the ID of the object, and that will never change. No maintenance needed....
"If you use helper/search functions globally, do you not sometimes find you're in a position where you have to find and update multiple calls to it if the wrong thing changes? Leaving you in a similar position to name map/alias updates?"
Don't understand what you're saying.. - Colin_McCraeCommunity HeroI get you.
If you are happy that an object ID will never change, then I can see how this would work for you.
But if an object ID did change. Or a parent object you use to start your search was removed, I assume you would have to go through all your scripts updating search calls?
Using Aliases to reduce the complexity of object references works very well if you do it well in the first place. To use Tez's object as an example:
Aliases.browser.pageMymome.panelUiDialogUiWidgetUiWidgetCon.formForm0.tableModalformwrapper.textboxQuestions0AnswerAnswertex
Now
Aliases.browser.pageMymome.panelUiDialogUiWidgetUiWidgetCon2.formForm0.textboxQuestions0AnswerAnswertex
Which looks very like a straight copy of the name map object. I wonder if it would have been possible to store the Alias as:
Aliases.browser.pageMymome.textboxQuestions0AnswerAnswertex
In the first place. So then when the intermediate parts ".panelUiDialogUiWidgetUiWidgetCon2" and "tableModalformwrapper" changed, you simply update the name map and updating that will correct the Alias without any further work. Thats the point of Aliases. To reduce complexity of object references and give you a "control layer" between the original name map and your scripts. At least, thats my interpretation of it anyway.
An example of one of mine is:
Sys.Browser("chrome").Page(my website).Panel("pageContainer").Panel("mainPage").Panel("contentContainer").Panel("mainContent").Panel(0).Form("create_user_form").Label(0).Select("creation_selection")
Has an Alias of:
Aliases.Browser.Website_GlobalControls.Form_CreateEstate.DropDown_Create
So if any of the intermediate panels change, I just update the name map. I don't have to touch the Alias or scripts that use it. I know the page will always be there. I know the control will always be there. So they are all that is included in the Alias. It's the intermediate stuff that is likely to change so it is excluded.
Its an interesting subject. And always a minefield. So I'm always interested to see how people approach it. - jose_pitaSuper Contributor"But if an object ID did change. Or a parent object you use to start your search was removed, I assume you would have to go through all your scripts updating search calls?"
Find & Replace :D
Now I'm starting to get why you're at ease with name mapping (I think). You have only 1 Sys.Browser("chrome").Page(my website) whether I have 50 or more of those, each with similar but different child objects.
I tried to use only 1 page object with * on the name, but then things got mixed up, panel A in page A was one thing and panel A in page B was a different thing... Had to give it up all together... - Colin_McCraeCommunity HeroNo.
Current project uses IE & Chrome. Many, many different pages over several sites and sub-domains. Alias file is around 15-20 pages at the moment. One of those being a "global" page which contains common objects used throughout the site but much more basic page identification properties so they work globally.
I use user-defined project variables to set base parts of the URL/domain and then two properties (at least) to identify the page so that I can split the URL and parameterize parts of it and use wildcards where appropriate. Full RegEx availability in object mapping properties would be even better, but wildcards just about do for the moment. Once I have the high level stuff well defined, I then use Aliases that are as short as possible (see above) for the lower level objects. So far, it's working well and problems due to changes have been very, very minimal.
Previous propject had multiple browsers open, sometimes a mixture of IE & Chrome. Using similar, but not the same URL's. I only used name maps for the very high level objects on that one as 95% of the objects on the pages were dynamic. So that one made much heavier use of search and helper routines. But I did find that slowed things down a bit.
Related Content
Recent Discussions
- 17 minutes agoashly