Categories

Descriptive programming in QTP

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 “http://google.com/“,””,””,””
Browser(“Google”).Page(“Google”).WebEdit(“q”).Set”quicklearnqtp”
Browser(“Google”).Page(“Google”).WebEdit(“q”).Submit
Browser(“Google”).Close
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 “http://google.com/“,””,””,””
Browser(“name:=Google.*”).Page(“title:=Google”).WebEdit(“q”).Set”quicklearnqtp”
Browser(“name:=Google.*”).Page(“title:=Google”).WebEdit(“q”).Submit
Browser(“name:=Google.*”).Close
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
URL=”http://www.google.com”
SystemUtil.run “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
GoogleBrowser.CloseAllTabs
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 comments to Descriptive programming in QTP

  • Nice one… I am new to QTP still able to get idea. Thanks

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

    Thanks,
    Raghu.

  • 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?

  • 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 ??

  • Anonymous

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

    thanks,

    Viveka

Add Comment Register



Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>