Saturday, May 31, 2008

Descriptive Programming

If the object is not in the object repository, then based on the unique property of the object we can write a program on that object. It is nothing but Descriptive Programming.

QTP cannot take an action on a object until unless its object description is in the Object Repository.
But Descriptive programming provides a way to perform action on objects which are not in Object Repository.

When to Use:

1. The object in the application are dynamic in nature and need special handling to identify the object.
2. 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.

Example for when to use DP:

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.

How to write Descriptive Programming:

There are two ways to write.
1. By creating the properties collection objects for the description.

To use this method you need to create an empty description
Set ObjDesc=Description.Create 'Now we have blank description in ObjDesc.
'Each description has 3 properties, they are Name, Value, RegularExpression.
ObjDesc("PropertyName").Value="Value of the Property"
'When you use the property name for the first time the property is added to the collection and 'when you use it again the property is modified. Now we can use it as ....
Browser("BrowserName").Page(PageName).WebEdit(ObjDesc) .set "Test"

'To Remove the property from the collections -
ObjDesc.remove"PropertyName"

'To know the property exist or not in the property collection -
If ObjDesc("PropertyName").value=empty then
msgbox "Not Exist"
else
msgbox "Exist"

2. By giving the description in form of the string arguments.

Browser("PropertyName:=PropertyValue").Page ("PropertyName: =PropertyValue")..........

No comments:

About Me

My photo
Hi all,I am Arun Singh Rajaputra. I am working as a Project Lead in a reputed organization in Hyderabad, AP, India. I have little bit knowledge on Quick Test Professional and like to share my knowledge to all through this blog.

Subscribe to get updates on this blog

Enter your email address:

NOTE

Some of the posts posted in this blog are collected and most of them have been prepared by me. If any one have objections regarding any copied posts. Please mail me so that I can take a necessary action on that post.