What is Descriptive Programming in Automation Testing QTP with Example





What is Descriptive Programming in Automation Testing QTP with Example

As all of us know that an object and related properties must be recorded in object repository to active the QTP to process the actions on it. And this is only possible by the Descriptive Programming

With the help of Descriptive Programming, we don’t save the object and related properties values in object repository but describe the value of property pair in script directly.

Main logic behind the descriptive programming isn’t bypass the object repository but help to identifies the dynamic objects.

So here we will discuss on the following:

  1. Introduction with Descriptive Programming.
  2. How you can apply or implement the Descriptive Programming?
  3. Where and when should use this Descriptive Programming?
  4. Some important points which need to keep in mind regarding the Descriptive Programming.


  1. Descriptive Programming Introduction: Descriptive programming will be used to perform the actions or operations on any object currently that is not available in the object repository.  Lot of valid reasons will be discussed further in this section for this.

  1. How you can write Descriptive Programming - We can used the descriptive programming by following two ways:

    1. By assigning description in the form of arguments of string
    2. By generating the collection of properties for the available description

  1. By Assigning the description in the form of String Arguments: This is very usually used style for Descriptive Programming. We c an directly describe the object in statement by specify the property like:
General Syntax will be:
TestingObject(“PropertyNameA: = PropertyValueA”, 
“….”, “PropertyNameB:=PropertyValueB”)

TestObject-the test object class could be WebEdit, WebRadioGroup etc….

To confirm which property and value pair need to use, we should use the object spy:
i.                 Go To Tools > Object Spy
ii.               Now select “Testing Object Properties” Radio Button.
iii.             Spy on the desired object
iv.             In the list of properties, search and write down the property and value that can use to recognize the object.

descriptive programming
descriptive programming


  1. By generating the collection of properties for the available description: The collections of properties also does the same thing as the string argument. Difference is only that this will collects all the properties of that specific objects in a object of that instance. Now you can easily referenced that object with the help of this instance. So to avoid the lot of writing for “string argument” multiple time again and again lot of times.  So According to me “string arguments” [1] function is too much intuitive and easier to work with that.

First you need to create one blank description to use this method
Dim obj_Desc  ‘Not required to declare
Set obj_Desc = Description.Create

You have now empty description in “obj_Desc. Each description has 3 properties “Regular Expression”, “Name” and “Value”.

Obj_Desc(html tags”.value= “INPUT”

First time when you will use the name of property, it added in the collection and when you want to use it again the property will be modified.;

Obj_Desc(“html tags”).value= “INPUT VALUE”
Obj_Desc(“Names”).value=”txt.*”

That mean an object along with html tag as INPUT and name starting wth txt. Actually regular expression will be “.*” . You will have to set regular expression property as FALSE if you don’t like to property “names” should not identified as regular expression.

            obj_Desc(“html tags”).value = “INPUT”
            obj_Desc(“names”).value = “txt.*”
            obj.Desc(“names”).regularexpression = “txt.*”

This is the style of creating a description. Now we will learn how you can use it:

Browser(“Browser”).Page(“Page”).WebEdit(obj_Desc).set “Test1”

.WebEdit(obj_Desc) mean definng one more property for available description which was not defined earlier and that is its text box.
(because QTPs WebEdit boxes map to text boxes n a web page).

If there is more than 1 element with similar description on the available page then we definitely must assign “index” property for such description.

Following HTML code will help you out:

<--!input type="”textbox”" name="”txt1_Name”"-->
<--!input type="”textbox”" name="”txt1_Name”"-->

Here HTML code has also 2 objects with similar objects description. That’s why to differentiate these two objects you will have to use the property called “index”.
Following is the description for all 2 objects:

For First textbox:
obj_Desc(“html tags”).value= “INPUT”
obj_Desc(“names”).value= “txt1_Name”
obj_Desc(“index”).value= “0”
For 2nd textbox:
obj_Desc(“html tags”).value= “INPUT”
obj_Desc(“names”).value= “txt1_Name”
obj_Desc(“index”).value= “1”
Following HTML Code need to consider below:
<--!input type="”textbox”" name="”txt1_Name”"-->
<--!input type="”radio”" name="”txt1_Name”"-->
Now let’s discuss on some generic questions provided below:

Q. How we can calculate the numbers of description explained in any collection?
A. Function obj_ChkDesc.Count will return the proper result

Q. How you can get rid of a description from any collection
A. obj_ChkDesc.remove”html tag” would remove or delete the tag of html property from such collection.

Q. How can one confirm that property existence in the collection?
A. Straight forward answer is “It’s not possible”. Because undefined property also added default in collections. To confirm the value we can use following query:
If obj_ChkDesc(“html tags”).value = blank then”.

Where and when descriptive programming should be used ..

Following situations are the responsible where Descriptive Programming should use:

First condition where Descriptive Programming should used due to its significant importance, It should be used when functions are creating in an external file. These functions can be directly used in various actions. Eliminating is also required if you are using per action object repository.

2. The Nature of objects available in application and required special handling to recognize the object. Good / Best Example will be click on link whch can change the user of application. Ex: “Logout()”.

What is Descriptive Programming
What is Descriptive Programming



















Virtual Objects with Example in QTP
Cross Platform Testing


QTP TESTING STEPS How to Record a QTP Script






No comments:

Post a Comment

Popular Posts