Monday, 13 July 2015

QTP - 31 - Descriptive Programming :

Normally Object and its properties are stored in OR to perform any operation on QTP. But there are few instances we prefer Descriptive Programming (DP) . few of the cases when we use DP are :

1) The first situation I can take is the unavailibility of the object. Suppose we want to automate an objet which is still in development phase. So we can't capture OR . So in this case we will prefer DP.

2) For Embeded or nested objects we prefer Descriptive Programming.

3) Suppose the application has 20 pages and all the pages contain same 5 objects. So in this case OR will store 20 X 5 =100 objects which are not needed actually due to replications. In this case a\we can use DP.

4) Suppose we need to write some business logic or any calculation validation , then in this case again DP is prefered.

5) We have an option of childobjects in DP through which we can count the number of objects in a page

6) Suppose the object's property kept on changing in application. Then to handle dynamically changing objects we use DP.

7) There are few objects which appears/or gets added in runtime. To handle such objects we use DP.


There are two ways to script using DP :

- Description Object (Dynamic)
Its the dynamic approach for the programming. Here we create a object and then assign a property to it.We add a collection of properties and values to a Description object, and then enter the Description object name in the statement. Script is developed using description Objects that depends upon the properties used and their corresponding values. Then these descriptions are used to build the script.

Set  Dbrowser=description.Create
Dbrowser("micclass").value="Browser"
Dbrowser("title").value="Gmail: Email from Google"

- Description String (Static)
In Description String the properties of the objects are defined in the statement. It is the static approach for programming

Example
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").Sync


No comments:

Post a Comment