Descriptive Programming in QTP/UFT: Dynamic & Static

What is Descriptive Programming?

Descriptive programming is used to execute operations on an Object in the AUT whose definition is not stored in the Object Repository. Using this mechanism, you can bypass identification from the Object Repository and supply the Object Description in the statement itself.

An object name is simply used to map an object in script with its description in an object repository. Meaning if you change the object name in your script and object repository, the script should run. Watch the following video on this concept

 

Video Highlights

  • Delete the Object Description of Agent Name Win Edit Box from the Object Repository. If you run the test again it will fail since it can not recognize the object. Let's examine the reason why the script is failing
  • During Run Time, Micro Focus UFT identifies the operation that is performed on WinEdit box and the Object Description in Object Repository is stored as Agent Name. It uses this name to track the object in an object repository. For a parent, you cannot have two child objects with the same name. Hence, QTP uniquely maps the object in the repository. It then uses the stored description in the Object Repository and replaces the name with the description. It then uses this statement to identify the object in the application under test/li>
  • Since in our case we had deleted this object description altogether the script fails/li>
  • But what if instead of QTP replacing the object description, you as a tester directly specify the object descriptions in your script. This is nothing but "Descriptive Programming"

Types of Descriptive Programming

You can use Descriptive programming in two ways

  1. Static
  2. Dynamic

Static Descriptive Programming

In Static Method, for object identification, you specify an object's property in the following format

property:=values,

This format is called property value pair and is enclosed in inverted commas>

If your object uses multiple descriptions for identification, you can specify those using commas>

So in our case, the description for Agent Name becomes

"nativeclass:=Edit", "attached text:=Agent Name:"

Dynamic Descriptive Programming

The second method of doing the same action is using Dynamic Descriptive programming

In case your script uses the descriptive programming object candidate multiple times, it will be very tiresome to specify all the property value pairs for each statement

In such cases, you can make use of Description Class provided by QTP

The syntax for creating a description object is

Set MyDescription = Description.Create();
MyDescription("property").Value = "property-value";

This is the Dynamic Method

Why Use Descriptive Programming?

YOU MIGHT LIKE: