techno13

Descriptive Programming In Qtp – Part 1

Hello Friends,
In this series of post, we’ll learn about Descriptive programming (DP).

There are two ways, QTP uses to recognize the objects present in your application.

1. Object Repository (OR)
2. Descriptive Programming (DP)

First let see how OR works. OR is the simple and default way of object identification in QTP. OR stores groups of properties and values of every object. While you record on application, all the objects you click, are stored in Object Repository.

During the play back QTP use this OR to identify the object on which the action is to be performed.

What is Descriptive programming (DP)?

We’ll use DP when we want to bypass OR. Descriptive programming is used when we want to perform an operation on an object that is not stored in the object repository. This way QTP wont search for the object properties in the OR, but will take it from the DP statement.

Why use Descriptive programming (DP)?

Everything looks fine while automating test using OR then why should I use DP?

Well, there might be many valid reason to do so. Think about a situation – you want to close all opened browser automatically before you start executing your script. Here OR will not help you to identify an object as it is not possible to store all the opened browser objects into OR. Make sense?

No worries! We’ll discuss the need and benefits of DP in detail later in this post. Well examine scenarios where ORs advantages are outweighed by the DP.

I am not very good in vbscript. Is it mandetory to learn vbscript explicitly to write DP?

No. Not at all! Its not mandetory, but yeah.. recommended. For basic opretions and starting with DP, this post will guide you.
Although, for advanced oprations i.e. using COM, AOM, complex framworks etc. vbscript knowledge is the key.

Okie guys! Now, lets start writing DP!

Writing Descriptive Programming (DP):

DP can be written in two ways..

1. Static (by provide the set of properties and values directly)
2. Dynamic (by creating description object)

Static:

– In Static method of DP, we provide the set of properties and values directly in a single line, in form of the string arguments.

Here is the format/syntax of DP..
object’s Class Name(“property name:=property value)
Exmp 1: webbutton(Name:=Google Search)

object’s Class Name = webbutton
property name = Name
property value = Google Search

Exmp 2:- Browser(google).page(google).webbutton(name:=Google Search,type:= Submit).click

In above statement, Browser(google) and page(google) are written using OR. And webbutton(name:=Google Search,type:= Submit) is written using DP. Please note that we can write multiple set of properties and values in any DP statement.

Examples:
webbutton(name:=Google Search).click

For full article, visit >>

Related Posts