Thursday, 1 September 2011

Descriptive Programming


Hi All,

  I this post I would like to discuss on descriptive programming one of the most important and complicated looking feature of QTP so I would like answer all the questions which arises when we start any new topic .
  
What is descriptive programming?

    As the name suggest it is some thing that is related to description then question comes into mind that description of what? So the answers is description of objects .As we know that QTP identifies the objects of AUT using the values of the properties available in object repository and in descriptive programming we give those values of objects with the help of descriptive programming so now there is no use to have those objects in OR .
We can provide the description of the objects in set line of codes and then QTP identifies that object in the behalf of the description.

When descriptive programming?

    As I have already told you that on using descriptive we can directly remove the OR stuff so basically we use descriptive programming when .

  •  We don’t want to use object repository at all.   
  •  Size of OR is too huge.   
  •  Objects and their properties are very stable. 


How to use descriptive programming?

  We use descriptive programming using two ways. 

  • String argument to access the objects.   
  •  Create object with the collection of their properties.


Step 1:  First of all we should identify the object of which description we want to create.
Step 2:  Now select that Object using Object Spy for Example if we have spy this edit box it will look like this.



                                              For browser:                              For page:                             


 Step 3: Then we have to identify the properties and its values because now we have to identify the object at run time with the help of giving the name of the object in the code itself.
e.g. for browser if we se title property is having value as “Google – Window Internet “
So reach to that browser we have write as browser(title:= Google – Window Internet) never forget to put “:=” colon then equal to sign .
 In the same manner we have to identify the page property and its value ,be very careful while selecting the property because it has to unique as compare to other object.

The above one was string format now if we talk about the (collection of their properties) we need to define a description class .

Set desc = description.Create
desc("micclass").value = "Browser"
desc("title").value="Google - Windows Internet Explorer*"

Example 1 : = This very common question in interview “Count the Number of links in a given page using DP”



Close 3rd  Open browser
Browser("CreationTime:=2").close
Since CreationTime starts from 0 and you very well manipulate these questions into many more new questions .

1 comment: