Monday 28 September 2015

When we use Descriptive Programming

Descriptive Programming which is also known as Programmatic Description provides a way to perform operations on objects that are not present in object repository. The words Descriptive Programming and Programmatic Description can be used interchangeably. We will be using Descriptive Programming.
When and Where to use Descriptive Programming?
We generally use this descriptive programming for the following reason given below
  • Handling Dynamic Object Property
  • Using External Function Library
  • Huge Object Repository
  • When Application is Not Ready Yet
  • Object Repository in read only or shared mode
  • Several Identical Objects needing Same Operations

Handling Dynamic Object Property:
One of the very useful place where we can use Descriptive Programming is when the object properties in the Application Under Test (AUT) 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.
For example if we consider a scenario of unsuccessful login then the values of  username changes repeatedly, I mean the text property of Link object above changes according to the username. It is easier to handle such properties with descriptive programming.


Using External Function Library:
Another place where DP can be of significantly important is when we have to create functions in an external file. We can use these functions in various actions directly, on eliminating the need of adding object(s) in object repository for each action. [If you use local object repository]. This forms the basis of keyword driven framework approach.

Huge Object Repository:
When object repository is getting huge due to the number of objects being added. Bulky object repository may decrease the performance of QTP while recognizing an object.

When Application is Not Ready Yet:
Suppose we have a web application that has not been developed yet. Now for QTP to record the script and add the objects to repository, needs the application to be up, that would mean waiting for the application to be deployed before we can start making QTP scripts. But if we know the descriptions of the objects that will be created, we can start-off with the scripts using Descriptive Programming.

Object Repository in read only or shared mode:
If we want to modify QTP script but the Object repository for the same is read-only or in shared mode i.e. changes may affect other scripts as well. In such a case, you may use Descriptive Programming approach.

Several Identical Objects needing Same Operations:
For example on a web application on the same page we have 15 textboxes on a web page and there names are in the form txt_1, txt_2, txt_3 and so on. Now adding all 15 objects in the Object repository would not be a good programming approach (since the object description would be the same except the index ordinal identifier.). We can simply go for Descriptive Programming.

For example If in different pages of a web application with several pages has 3 navigation buttons on each page. Let the buttons be “Cancel”, “Back” and “Next”. Now recording action on these buttons would add 3 objects per page in the repository. For a 10 page flow, it would mean 30 objects which could have been represented just by using 3 objects. So instead of adding these 30 objects to the repository, we can write 3 descriptions for the object and use those descriptions on any page.

No comments:

Post a Comment