What is Descriptive Programming?

QTP cannot take action on an object unless its object description is in the Object Repository. But descriptive programming provides a way to perform action on the objects by identifying them by their properties. Few of the properties using which an object can be defined are name, text, innertext ..etc,. Each object should be identified uniquely by QTP either by using single property or multiple properties.
For example: If a Text box in a web page has the property 'name' as 'UserName' defined in the application and no other text box in the application has the same name, and if we want to write name as ABC in the text box. then,

Browser("..").page("...").WebEdit("name:=UserName").Set "ABC"
Here using the properties within the Brackets for 'Browser', the browser is identified uniquely. using similarly, using the properties within the Brackets for 'Page', the page is identified uniquely. Finally the edit box is identified using the property 'name' of the edit box and the value ABC is set in the text area.
One need to be able to identify the objects uniquely in AUT with their properties and should have enough knowledge of VB Script to generate script.

Descriptive Programming is used when:

The object in the application are dynamic in nature and need special handling to identify the object.

When object repository is getting huge due to the no of objects being added. If the size of the object repository increases too much then it decreases the performance of QTP while recognizing the object.

If you want to take action on similar type of object i.e. suppose we have 20 Editboxes on the page and there names are in the form edt_1, edt_2, edt_3 and so on. Now adding all 20 edit boxes description in Object repository would not be a good programming approach.

Suppose, we have an application that has not been developed yet.Now QTP recording the script and adding the objects to the object repository needs the application to be up. That would mean waiting for the application to be deployed.But if we know the description of the objects that will be created then we can still start of with the script writing for testing.

No comments: