Descriptive programming in QTP

By | January 14, 2011
Descriptive programming in QTP.
Descriptive programming is the smartest way for automation in QTP.
Descriptive programming in QTP is much different from simple record and play method.
Following are some important points regarding descriptive programming in QTP.
  • It doesn’t require recording the page and so no need worry about object repository. 
  • You can optimize your code.
  • Before starting descriptive programming you need to know about object properties and their values, using object spy you can see each object’s properties.
Let’s learn descriptive programming in qtp in a very simple and practical way.
I have given 3 different examples which uses different method for automation in QTP.
Using object repository method: Example 1
Following QTP script is the simple example of record and play method.

SystemUtil.Run ““,””,””,””
Now, you want to write above script in descriptive programming. For that you need to get all object properties using “object spy” tool. E.g Browser is the parent object and its property is “Name=Google” and Page is the child object whose property is “Title=Google”.
Now understand following example which is the combination of “record & play” and “descriptive programming” method. You can say hybrid programming.
Hybrid programming: Example 2

SystemUtil.Run ““,””,””,””
Note: Don’t copy and paste and try to run above examples because it requires object repository to execute.
Now at this point you may be very well aware of hybrid programming (combination of descriptive programming and using object repository method).
Following is the example of pure descriptive programming in QTP which you can copy and paste to QTP (Tested with QTP 10 and IE 8) and can execute it.
Descriptive programming in QTP: Example 3

‘Variable declaration
Dim GoogleBrowser
Dim GooglePage
Set GoogleBrowser=Browser(“name:=Google.*”)
Set GooglePage=GoogleBrowser.Page(“title:=Google.*”)
URL=”” “iexplore”,URL
‘Write ‘quicklearnqtp’ in search box
GooglePage.WebEdit(“name:=q”,”type:=text”,”html tag:=INPUT”).Set “quicklearnqtp”
‘Click on Google Search
GooglePage.WebButton(“name:=Google Search”,”index:=0″,”type:=submit”,”html tag:=INPUT”).Click
‘Close browser
I hope you gained a lot on descriptive programming technique from this post.I will provide more real time examples and  details on descriptive programming in QTP in my next post. Let me know your inputs on descriptive programming in QTP and share your feedback.
If you like this article, You can subscribe through mail.

5 thoughts on “Descriptive programming in QTP

  1. raghu sharma

    Really a goood one for starters in this QTP ..!! Thanks alot for providing yur such an interest towards QTP in the view of starters.


  2. Bobinho

    Hi, i have been an automator for quite a number of years now and have dabbled with descriptive programming, but i am still a big fan of the GUI Map concept.

    How does descriptive programming handle changes to an object? If i have references to that object in functions and tests, would i not need to find them all and update them manually as apposed to just updating the GUI Map and those changes filtering through to my references automatically?

  3. Vinay Sagar

    It was really a nice one. Thank you very much.

    Can you give some examples on Dynamic applications.Because in some situations, the name or Property value my change. So can you tell me how to use Descriptive programming in such situations ??

  4. Anonymous

    it’s a good start for beginners!-Good job.Keep it up!




Leave a Reply

Your email address will not be published. Required fields are marked *