3

What is descriptive programming in QTP?

Motti
  • 110,860
  • 49
  • 189
  • 262
lina
  • 63
  • 1
  • 1
  • 2

17 Answers17

8

Creating a test without using the object repository is known as descriptive programming since you describe the objects as part of the script.

e.g.

Browser("title:=Google").Page("title:=Google").Link("text:=Advanced Search").Click

Note the := in the test objects' names, this is not a smiley it means that the property title has value Google (as a regular expression).

You can also use the Description object via Description.Create.

You can see more details here.

Motti
  • 110,860
  • 49
  • 189
  • 262
  • 2
    Let's add that it descriptive programming is useful whenever you want to address an object whose identification attributes' values vary, and which cannot be described efficiently using a regular expression. And: Since QTP began to support parametrized identification properties (i.e. the attribute value is not a literal, but a parameter placeholder replaced by the parameter's value at run-time) (in 9? or 10?), you do not have to depend on descriptive programming as often as earlier when this feature didn' exist. – TheBlastOne Jul 20 '10 at 11:41
  • @TheBlastOne - How do you check if a web element exists when using dynamic descriptive programming ? In static, its .WebElement(properties).Exist(time). – MasterJoe Jun 15 '17 at 23:33
  • Why don´t you post this as a question? (I use .ChildObjects with the parent object, and check if the result collection has 1 item.) – TheBlastOne Jun 16 '17 at 17:32
2

descriptive programming is writing qtp scpriting without any object repository

Anil
  • 665
  • 1
  • 10
  • 14
2

Descriptive programming is used when you want to perform an operation on an object that is not present in the object repository.

Setting the value of a Text Box

Browser(“Browser”).Page(“Page”).WebEdit(“Name:=textbox_name”,”html tag:=INPUT”).set “My New value”


Read More
Check out this extensive article about the topic
http://www.learnqtp.com/descriptive-programming-simplified/

Ankur Jain
  • 236
  • 1
  • 8
Jonas Söderström
  • 4,856
  • 2
  • 36
  • 45
1

Descriptive programming is used in many scenarios like

  • When QTP is not able to identify objects from properties value stored in Object Repository.
  • When user do not want to use object repository or bypass it.
  • When user wants to write a piece of code that can run on more than one website. For eg.when we want to print the name of all link on Google or yahoo, we can use same piece of code using common property value

It is used in two ways:

  1. Static Descriptive programming

    Here we use properties and values directly in test script to access an object. For eg.

    Browser("micClass:=.....").Page("micClass:=...").Link("micClass:=...")
    

    Note: We can start Descriptive programming at any time, but once started we can not use Object Repository till the line is finished.

  2. Dynamic Descriptive programming

    Here we create a description object and then operate on that. For eg.

    Set objTest = Description.Create
    objTest("micClass").Value = "Link"
    objTest("name").value = "Click Here"
    
halfer
  • 19,824
  • 17
  • 99
  • 186
Mfs_Dheeraj
  • 104
  • 4
0

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 won’t search for the object properties in the Object Repository, but will take it from the statement.

Messiah
  • 99
  • 7
0

Using Descriptive programming we can define an objects in the QTP without using the OR (object repository) Here is a good tutorial that describes three ways to do descriptive programming: http://www.bytetips.com/descriptive-programming-in-qtp/

0

Browser("title:=Google").Page("title:=Google").Link("text:=Advanced Search").Click is not a Descriptive programming, it is bad practise. Parameters should be separated from code, so you change them in 1 place, Object Repository file in this case.

What is Descriptive programming - when you use Description object:

Dim oDesc        'Description Object
Dim colObject    'Object Collection

Set oDesc = Description.Create
oDesc( "micclass" ).value = "Link"
oDesc( "text" ).value = ".*ma.*"  'Images
oDesc( "text" ).regularExpression = False

Set colObject = Browser( "Google").Page("Google").ChildObjects( oDesc )

So idea is to use description to get collection and search for your element in that collection.

0

What I can say about descriptive Programming is We use Descriptive Programming when we don't want to use Object Repository. Many people said they used descriptive Programming in agile development mode, in which they start creating automation scripts while application was still in development (in agile mode).

We use descriptive programming, when some objects are dynamically changes object properties and with given set of assertive properties it is difficult to identify object,without compromising script performance.

0

Descriptive Programming is used to perform operations on the object which we are not present in qtp.It uses [Property ->value]. Please refer below link:-

Descriptive Programming Simplified

Ankur Jain
  • 236
  • 1
  • 8
0

Identifying the objects in your page without Object Repository with special property The most used for Descriptive objects when you have more than one object in the same page with same E.g. HTML ID and you need to click on all of it ... you can return all objects and making loop to click on the object that you identify in object script with it's property(s)

0

Aside from all the repetition above, I would say that it's the best and most lightweight way to work with QTP, vbscript is the easiest of languages and even considering that, you are only going to be using a small portion of it.

Also re. descriptive programming, there is static descriptive programming, and Dynamic descriptive. Static is creating a variable for each object you want to identify/interact with (ie. dim myBUTTON ) and then giving descriptions of that actual button to the variable.

It's fine and functional, but as Artem pointed out above, the Dynamic version (which he shows you in perfect code) is far more reuseable and friendly and better looking in terms of keeping your code tidier. You make one description object, and continuously redefine6 it for the various needs you have, so (using Artems naming convention) oDesc can become a button that you click, a link that you click, and you can keep redefining it as you go down your code (by giving the same properties/values to that object). It's tidier, and you don't have a million variable names flying all over the place so it's clearer. Dynamic descriptive programming ! There's some fine-aspects to it and trouble shooting depending on which values you pass to your object, so feel free to contact me anytime, Y.

0

In Simple words we can say Describing the object via Code, Instead of Object repository.

Sample Code

Browser("title:=Google").Page("title:=Google").Link("text:=Advanced Search").Click

Object Based Code

Browser("Google").Page("Google").Link("Advanced Search").Click

And you Need object for all

JGK
  • 138
  • 3
  • 15
0

Think of it as finding a location (like finding the object), object repository works as a map app (e.g., Google map), you just have to give the recorded location and it will find it for you.

Descriptive programming is basically you understand the object and its elements. It means you know way to go home or at least have a map with you in order to find the location.

Both have pros and cons. Say if your phone is dead, or there's no network, Google maps (object repository) won't work for you anymore. You have to go with a native way.

gung - Reinstate Monica
  • 11,583
  • 7
  • 60
  • 79
0

Descriptive programming is used to completely avoid the use of an object repository or avoid adding similar kinds of objects in the object repository. To understand all possible uses of descriptive programming with examples please refer to https://myskillpoint.com/descriptive-programming-in-uft-with-examples/

0

The Description of objects like properties and values that we are specifying directly in the test script is called descriptive program Mainly we can use descriptive program without using object repository.

greeness
  • 15,956
  • 5
  • 50
  • 80
venu
  • 1
-3

"Descriptive Programming" is a misnomer.

It's used, very misleadingly, as a synonym for 'Dynamic Object Recognition'.

Marek Sebera
  • 39,650
  • 37
  • 158
  • 244
-4

Writing descriptive level programming for the qtp

Anil
  • 665
  • 1
  • 10
  • 14