This is a frequently being discussed question within test automation teams while you are planning for an automation. I have also observed this question being asked in interviews as in “which way you would like to go for Object Repository or Descriptive programming?’ I believe there is no “verses” here, i.e. it is not something to choose between Object Repository or descriptive programming.
The way I see to it, is two different features of QTP meant for different purposes. It basically depends on the needs of the test, at some point you may need and simply use object repository and at some point there is no way without using Descriptive programming.
A simple example, lets say if you have to click on a link on a page. Its a very simple scenario, where simply adding the object into object repository will do the required. But in the same situation if you 100 links on the page and you need to verify each one of those by clicking. In this case its not good to have all the 100 objects in the OR whereas we should use descriptive programming here.
But in the case where you have to decide (irrespective of the need of test, I see many people create frameworks and decides not to use object repository and go with descriptive programming only) whether to go for either Object Repository or descriptive programming, I prefer to go with Object repository mostly (not very much convinced with “only” descriptive programming approach). Not only because it has been built for that purpose but it makes our life easy in multiple sense.
Here is another example, you have a page where you have a button with text as “Submit”. You have developed your script for the button click. Now in the next release the button text is changed and becomes “Submit Order”. if you have used Object Repository, you just need to change the text property of the button. All scripts using that repository will be updated automatically. But In case of Descriptive programming, you will have to manually modify every script requiring the update. I understand that we can definitely sort this out in scripting as well. I have some more pointers 🙂 Descriptive programming statements need to be implemented manually. Finding a set of properties to uniquely identify the object consistently can be time consuming. To help with selecting the properties, you can use the Object Spy or temporarily add the object to the repository.
QTP/UFT identifies an object using a set of property/value pairs that uniquely identify the object. When determining whether to use the object repository or descriptive programming, you should consider how the property/value pairs are selected and used.When objects are learned into the object repository, QTP/UFT automatically determines which properties and values are needed to uniquely identify the object. QTP/UFT starts with a predefined set of mandatory properties that must be learned. If those properties do not uniquely identify the object, QTP/UFT includes predefined Assistive properties, one at a time, until there is a unique identification. If the mandatory and assistive properties do not uniquely identify the object, QTP/UFT includes an ordinal identifier. In addition to these properties, if Smart Identification is enabled for the object class, QTP/UFT will learn additional properties that can be used during replay if the defined object definition does not match an object in the application. During replay, if QTP/UFT cannot find an object using the defined properties or smart identification, an error (“Cannot identify object”) will be generated.
QuickTest Professional (QTP) / Unified Functional Testing (UFT) can perform faster when using information from the object repository to identify the object. When QTP/UFT first encounters an object during replay, it uses the object description (from the Object Repository) to create a temporary version of the test object. For the remainder of the test run, QTP refers to that temporary version of the test object rather than to the test object in the object repository. This internal “mapping” helps QTP locate the objects quickly. Statements using descriptive programming can be slower. This is because QTP/UFT must check every object and compare it with the specified properties to find a match.
When descriptive programming is used, all property pairs that are listed are considered mandatory. You must manually create the property list to identify the object at runtime. During replay, if QTP/UFT cannot find an object using the defined properties, an error (“General Run Error” or “Cannot identify object”) will be generated. To help with selecting the properties, you can use the Object Spy or temporarily add the object to the repository.
additionaly Descriptive programming is useful when you need to perform an operation on an object whose properties match a description determined dynamically during replay.
Example:OrderNo = 4 ‘ assume the order number is generated during test execution
Window(“Flight Reservation”).WinEdit(“attached text:= Order No:”, “text:=”& OrderNo).Highlight
If you will be using the object description in multiple statements, you can create a Description object to hold the description.
Let us know your views on this, which one you prefer to go with and in what scenarios.