| || |
What are the benefits of using Descriptive vs an OR??
So I can't figure out why people are always preaching descriptive programming vs an OR and I want to hear everyones thoughts. Here is my experience with this topic. An Object Repository can do everything that descriptive programming can do, but you avoid several issues:
1. With Descriptive, you can misspell something in the whole string
2. With Descriptive, you have to use object spy and get all of the properties, it is much slower than with OR
3. With descriptive, you do not get the intellisense
4. When descriptive fails, QTP does not throw an error that the object can't be identified, debugging is more complicated
Plus I'm sure there are many more issues with descriptive. I know how to use it and I definitely do. But 90% of the time, I use an OR. I had a competition with someone that does descriptive and in the time that they identified one object, I probably could have had 10 identified.
Anyways, can anyone make a good argument as to why I should use descriptive over an OR?
Descriptive if done right can be more powerful selection wise, more stable, and easier to mass refactor (if done right). Since you pick the exact properties, such as unique ids or attributes that are set by developers vs. those that are auto-generated by the resource manager. However, this can be very slow if you're doing deep finds. Generally if you're doing descriptive programming, you want to encapsulate it inside a object library, so you can expose them as aliases and have the same benefits of intellisense and make them easier to refactor by centrally locating them in once place.
Using an Object Map is generally faster. It tends to use recorded object indexes and parent/child relations, to avoid deep find() calls. To get around the maintainence issues for that, they created an GUI object tree to allow you to manage the objects centrally. This is very good for small changes in the UI when you need to remap the object to different aliases. However, it can be difficult to refactor large breaking changes. For example, if a object was buried deep in one grid and you're mapping a parent based on it's child contents; then child was moved to another part of the table, it becomes a big mess and generally easier to just discard the entire object map for that screen at that point and re-record the mappings. Discarding an object map and rerecording should be pretty easy so long as you remember to create aliases to objects you have mapped. You then just reassign the aliases back to the new objects.
Personally, I like descriptive as I have better control of how I structure my code. For example, say I want to support multiple tabs. In descriptive programming, I can write my code in such a way I can parameterize which tab I target. I think descriptive programming works best when you have access to the source code and can insert your own identification IDs. When you can't insert locators, it becomes a big mess having to isolate unique properties and writing deep find statements to target those.
You can also do both. Although this is messy, you can use object recognition to identify container level elements, then use descriptive programming to find the target element in a smaller subset of objects in that container's children. This improves the speed of descriptive programming by avoiding deep finds on parent elements.
Last edited by dlai; 09-25-2013 at 04:10 PM.
Hi Smart, It's wise to go for OR to avoid errors and confusions but certainly some scenarios we need to use DP.
In below scenarios you cornered with DP option
1. Select a check box from 100's of checkboxes with dynamic value
2. Select value from table which can be populated in dynamically
we can keep on adding scenarios like this. For me i was always like this approach.
There are several corner cases an OR can't cope with e.g. objects for which the only unique property is a name and that name is dynamic and depends on what data has been retrieved in a search. DP is very good with dynamic content.
An OR can also lead to duplication as well e.g. if you have an applet that is reused across pages and applications the objects in the applet are independent of where it is used but people tend add the applet and all its objects to the OR as a child everywhere it appears. Then if something in the applet changes and you have 40 instances of that applet you have a lot of OR to update.
But even with an OR I wouldn't rely on QTP to select the right recognition properties, I'd validate them using the object spy anyway. In your little competition, it is not a fair competition unless you compare how robust the results are against change. The little bit of extra work up front could save a whole lot of maintenance work down the track.
I think it would be almost impossible to use an OR with a good Keyword/Data Driven Framework, if not impossible certainly less flexible than using a DP approach.
In my experience here are some things DP is easier with than OR
Recursive looping through nested objects
Mark, I wouldn't say almost impossible unless maybe if you were considering only an OR. It is pretty easy to have a good framework with an OR for most objects and DP for the hard stuff. Even localisation is pretty easy if your devs are nice enough to give you unique ids to recognise your objects. Even if they don't if it's a web app, I've been able to use js calls exposed in the inner html to uniquely identify objects in any language. You just need to be a little more creative.
Hey David, thanks for your response! I have some counter arguments:
1. " Since you pick the exact properties, such as unique ids or attributes that are set by developers vs. those that are auto-generated by the resource manager.". QTP has object Identification window that you can quickly configure based on the application, and now all of your objects will be recognized with those unique properties that you desire. Much faster than descriptive.
2. Refactoring an OR, is very easy and its as simple as cutting and pasting objects. Or I can even use a combo of descriptive and an OR.
To all your other points, you mainly just claimed the benefits of descriptive, but you did not mention as to why it is better to use than the OR. Everything you mentioned can be done with an object repository, but in a faster manner.
In regards to tabs, descriptive programming is definitely better, but it is an exception. I am trying to figure out why so many companies want strict descriptive programming. As of now, it seems that I can still do everything much faster and more efficiently with an OR...
Yes, I understand that there are these scenarios. I am not saying that I will only use an OR. But, these are EXCEPTIONS. Why should I use descriptive for all of the objects to be recognized when it is SO much SLOWER? And by the way, I can do dynamic values in an object repository as well with QTP. For these purposes, I will use descriptive, but I am positive that by using an OR, I will develop scripts much faster than by using descriptive for everything. WHat do you think?
Hey Brendan, thank you for the reply,
Let me bring up some counter arguments.
1. "objects for which the only unique property is a name and that name is dynamic and depends on what data has been retrieved in a search". This is false, I can easily handle dynamic properties in an OR in QTP using regular expressions or parameterized values. And again, no object spy wasting my time and less chance of typing errors.
2. "Then if something in the applet changes and you have 40 instances of that applet you have a lot of OR to update." This is an improper use of the OR! THey should make it Shared, then there will be only 1 instance. Same thing can be said for the descriptive strings. If someone codes 40 instances of one object, then, they have to change it everywhere if the object changes. But for me to change, all I have to do is run my script in maintenance mode and it will automatically stop when it sees broken objects. With descriptive you have to search for the broken object.
3. "But even with an OR I wouldn't rely on QTP to select the right recognition properties". QTP has an option to configure the properties you want it to select. I modify these based on the application and then my objects are correctly identified all of the time! Sure, this takes skill and knowledge, but so does descriptive.
4. "In your little competition, it is not a fair competition unless you compare how robust the results are against change". I disagree, I have done both methods and I can tell you that an OR is much less maintenance. If we think about the process to add one object with descriptive vs one object to an OR, it is MUCH MUCH faster to add with an OR. I am not talking about recording, I add my objects one by one just like with descriptive. Now, multiply this speed by 1000 objects and I complete scripts much faster with an OR.
What do you think? By the way, how many of you actually tried using an OR in QTP to add objects, without recording? DOing it manually, one by one?
I hope I am not coming off as condescending by disagreeing with everyone. In fact, I sincerely appreciate everyone taking their time to help my dillema. I respect every Automation Engineer and I am thankful to have the opportunity to discuss this with bright individuals such as yourselves. My main goal here is to find out why using descriptive for all of your scripting is better than an OR.
I used to use descriptive all the time, for everything. Until a coworker convinced me otherwise. He showed me that an OR can do EVERYTHING we do with descriptive, but faster. THere are exceptions of course, but I am speaking of regular day to day object recoginition. But I was very surprised because I didn't know that the OR can do so many things. Maybe you guys are in the same boat? Or am I missing something haha? Thanks again.