QTP Descriptive Programming with real time examples

In this post i have explained QTP Descriptive Programming which is very useful in HP QTP to prepare Test Scripts for Application Under Test (AUT).By this topic you will get clear idea about QTP Descriptive Programming and explaining with real time examples.

QTP Descriptive Programming with real time examples

What is Descriptive Programming in QTP?

Descriptive program is a type a type of script using in HP QTP where we don't require any Object Repository for Application Under Test means in case we declare description of the objects in Test Script itself then that program is called Descriptive Programming in QTP. To execute Test script which is developed by Descriptive Programming then we don't require any Object Repository and Test Scripts execute with expected speed means good performance.

In case object repository is exist then QTP tool take some time to execute the script why because if Object repository is increasing wit number of objects of Application then Test scripts execution will take some time in order to identify the objects in application through Object Repository.

Advantages of Descriptive Program

  • Test Script execution is fast. 
  • It is easy to identify the objects in Application.
  • Object Repository is not required.

Disadvantages of Descriptive Program

  • Time consuming for Preparing Test Scripts.
  • Require each field objects while preparing Test Scripts(Proof Of Controls)

Syntax :

 Browser("Property Name:= property Value","p2:=pvalue").page("Property Name:= property Value","p2:=pvalue").WebEdit("Property Name:= property Value"").Set "xxxxxx"  

In above code we have specified object property names,property values in script itself ,most of the Test Scripts prepare with this type of statement,for examples see below codes.
1:  Browser("name:=Registration").Page("title:=Registration").Click  
2: Browser("name:=Registration").Page("title:=Registration").WebEdit("name:=Firstname").Set "Rajesh"
3: Browser("name:=Registration").Page("title:=Registration").WebEdit("name:=Lastname").Set "kuchana"
4: Browser("name:=Registration").Page("title:=Registration").WebList("name"=Select x").Select "Male"
5: Browser("name:=Registration").Page("title:=Registration").WebCheckBox("innertext:=insurance").Set "on"
6: Browser("name:=Registration").Page("title:=Registration").WebButton("name:=Submit").Click

Like this we can prepare Test Scripts with Descriptive Programming ,lets see above code with clear explanation,here i have taken
Browser("name:=Registration")
for above when we open any registration or Sign up page we will see page title and page name as per the objects we have to write the code with the help of Proof Of Control like below.
1:  First Name:   
name - Firstname
html tag - FN
innertext - First Name
2: Lat Name:
name - Lastname
html tag - LN
innertext - Last Name
3: Check Box:
name - insurance
inner text - insurance
inner html - insurance
html tag - na

According to above details we will prepare Test Scripts for Application using QTP.

In this Descriptive Programming another method is there i.e Description of Object ,it is written in Descriptive Programming where we are creating Description for objects and created objects uses in Test scripts as below example,

Read Also QTP Synchronization , QTP Mid Function

Syntax for Description Object

1:  Set Object Name = Description.Create  
2: Object Name("Property Name").Value = "Property Value
Lets see the Examples:

Count No of Links in Web Page

Here we are using Descriptive Programming with Description of objects in below code.
1:  Set Desc = Description.Create  
2: Desc.Add "micclass","Link" (or) link("micclass").value="Link"
3: Set Objs = Browser("name:=Best Online Courses").Page("title:=Best Online Courses").ChileObjects(Desc)
4: LinkCounts=Objs.Count
5: MsgBox(LinkCounts)

Lets see the explanation for above code
as we are created Desc object here used micclass property name for Link i.e property value.
  • Property Name = micclass.
  • Property Value=Link.
  • Child Objects.
  • Link Counts to count number of Links of Objs.
Used child objects to store all available links ,Child objects which are display in the window i.e those are container objects in Web page and web page is in Browser like mostly we will use for Text Boxes,Links etc.

Conclusion:

I wish every reader should get good knowledge on QTP Descriptive Programming and i have given with examples,please provide your valuable feedback on my post and comments.Please share in case you like my blog post so that at least one person may get good knowledge on Descriptive Programming.

Post a Comment

1 Comments

  1. This is really interesting, You are a very skilled blogger.
    I've joined your feed and look forward to seeking more of your wonderful
    post. Also, I've shared your website in my social networks!

    ReplyDelete