There is no specific answer as to which of the two (object repository or descriptive programming) is better.
There are certain situations when using descriptive programming has its own benefits (with descriptive programming along with other features you also get code portability) while in some other typical situations object repository works like a charm (No need to adjust the script when an object properties change, Highlighting an Object in Your Application etc are couple of features you can’t just resist and of course there are many more).
Below you can find some of the differences between object repository and descriptive programming. (Differences are not limited to what is shown below, there can be many more)
Object Repository
|
Descriptive Programming
|
With object repository QTP automatically resolves which properties and values are required to uniquely identify an object. QTP starts with predefined mandatory and assistive properties in that order. If the mandatory and assistive properties do not uniquely identify an object, QTP uses an ordinal identifier. QTP can also use Smart Identification (if enabled).
|
With descriptive programming set of property/value pairs are created by you and all are mandatory, although you can use object spy to get help in selecting set of property/value pairs.
|
Object repository in QTP is created automatically (manual creation is also possible) as and when you record on the application.
|
Descriptive programming statements need to be put into operation manually. Finding a set of properties to distinctively identify the object time and again can be time consuming.
|
Object repository is considered relatively faster if you take into account the performance for large applications.
|
It is considered relatively slower to create and performance wise also in case of large applications.
|
Object Repository
' Enter Email id in Username Field
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Email").Set "qtpworld.com"
'Enter password in Passowrd Field
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebEdit("Passwd").Set "qtp"
'Cick on the Sign In Button
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Click
Descriptive Programming
'Descriptive object to identify Browser with a particular title
Set Dbrowser=description.CreateDbrowser("micclass").value="Browser"Dbrowser("title").value="Gmail: Email from Google"
'Descriptive object to identify Web page with a particular title
Set Dpage=description.CreateDpage("micclass").value="Page"Dpage("title").value="Gmail: Email from Google"
'Descriptive object to identify a particular Web Button
Set Dbutton=description.CreateDbutton("micclass").value="WebButton"Dbutton("name").value="Sign in"
'Descriptive object to identify Web Text Box
Set Dedit=description.CreateDedit("micclass").value="WebEdit"Dedit("name").value="Email"
'wait till browser loads
Browser(Dbrowser).Page(Dpage).Sync
' Enter Email id in Username Field
Browser(Dbrowser).Page(Dpage).WebEdit(Dedit).Set "qtpworld.com" Dedit("name").value="Passwd"
'Enter password in Passowrd Field
Browser(Dbrowser).Page(Dpage).WebEdit(Dedit).Set "qtp"
'Cick on the Sign In Button
Browser(Dbrowser).Page(Dpage).WebButton(Dbutton).Click