Tuesday, July 8, 2008

Can we create test scripts in QTP without using object repository or objects?


Whenever QTP records any action on any object of an application, it adds some description on how to recognize that object to a repository of objects called object repository. QTP cannot take action on an 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.

Below are some of the situations when Descriptive Programming can be considered useful:

1. The objects in the application are dynamic in nature and need special handling to identify the object. The best example would be of clicking a link which changes according to the user of the application, Ex. “Logout <>”.

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

3. When you don’t want to use object repository at all.

4. Modification to a test case is needed but the Object repository for the same is Read only or in shared mode i.e. changes may affect other scripts as well.

5. When you want to take action on similar type of object i.e. suppose we have 20 textboxes on the page and there names are in the form txt_1, txt_2, txt_3 and so on. Now adding all 20 the Object repository would not be a good programming approach.

There are two ways in which descriptive programming can be used

By creating properties collection object for the description.

Dim obj_Desc ‘Not necessary to declare

Set obj_Desc = Description.Create

obj_Desc(“html tag”).value= “INPUT”

obj_Desc(“name”).value= “txt.*”

obj_Desc(“name”).regularexpression= “txt.*”

Browser(“Browser”).Page(“Page”).WebEdit(obj_Desc).set “Test”

By giving the description in form of the string arguments.

Browser(“Browser”).Page(“Page”).WebElement(“Name:=txt_Name”,”html tag:=INPUT”,”Index:=0”).set “Test”

No comments: