What is Descriptive programming in QTP?

What is Descriptive programming in QTP?
QTP performs an action on the object(s) of an application and while recording, it stores the object description to a repository called object repository.Objects within an application have their own unique characteristics which differs them among each other.
While running it reads the same description and performs an action on the respective objects.
DP Basics

DP Basics

Why Descriptive Programming?
If the object descriptions itself are changed or removed then DP saves us from pulling hair.
We write an objects description through scripts alone.
Lets have a simple demonstration on this topic:
Recorded script:
Browser(“Rest”).Page(“we love u”).Image(“vegies”).Click
Here object description is stored in the object repository and QTP learns as follows:
Browser title is Google
Page title is we love u and
Image name is vegies and it performs click operation on this page.
Now, next turn is to let QTP learn without using objects description from object repository. Here descriptive programming comes in handy!
Technique no. 1:
Browser(“title:=Rest”).Page(“title:=we love u”).Image(“File name:=vegies”).Click
Now QTP dynamically recognize the objects and performs an action upon them.
Technique no 2:
Dim oDesc ‘Object description object.
Set oDesc = Description.Create()
oDesc(“html tag”).value= “Image”
oDesc(“name”).value= “vegies”
Browser(“Rest”).Page(“we love u”).Image(oDesc).Click
This is the basic fundamentals on descriptive programming, i tried to simplify as much as i could. Wish you good luck ahead. “Miles to go before i sleep” 🙂

‘********Following DP script works independent of OR*******

‘Open google home page
‘ Verify whether iGoogle link is available..
If Browser(“Title:=Google”).Page(“Title:=Google”).Link(“Text:=iGoogle”).Exist(1) Then
‘ Click on iGoogle link on google home page
‘Print message
Print “Link cannot be found”
End If

One response to this post.

  1. Posted by atul on September 29, 2011 at 6:20 pm

    Can you please tell which Technique is mostly used in the Industries? 1st or 2nd?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: