Wednesday, 13 July 2016

Descriptive Programming

What is Descriptive Programming(DP)?
-Entering Objects Information directly into the test script is called descriptive programming.In DP, we will be "manually" specifying the properties and values by which the relevant object will be identified. This way QTP won’t search for the properties data in the Object Repository, but will take it from the DP statement.

-Object Spy is used to get the properties and their values to uniquely identify the objects in the application. If we know such
   properties and their unique values that can identify the required object without ambiguity, we need not use Object Spy.

What is the Need of DP?
During the automation, we always encountered with the objects whose properties are frequently changing(Dynamic in nature). To handle all these objects QTP provide a unique way of handling these kind of object which is DP.

Types of DP:
There are two types of DP Static DP and Dynamic DP

Static DP:
We provide the set of properties and values that describe the object directly in a VBScript statement.

Example-
'Launch gmail
systemutil.Run "iexplore.exe","http:\\www.gmail.com" 

'Wait till browser loads
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").Sync 
' Enter  Email id in Username Field
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebEdit("name:=Email").Set  "vb-excel.blogspot.in/" 
'Enter password in Passowrd Field
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebEdit("name:= Passwd").Set  "qtp" 
'Cick on the Sign In Button
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").WebButton("name:=Sign in").Click

Dynamic DP:
We add a collection of properties and values to a Description object, and then enter the 
Description object name in the statement

Example-
Set  Dbrowser=description.Create
Dbrowser("micclass").value="Browser"
Dbrowser("title").value="Gmail: Email from Google" 
'Descriptive object to identify  Web page with a particular title
Set  Dpage=description.Create
Dpage("micclass").value="Page"
Dpage("title").value="Gmail: Email from Google" 
'Descriptive object to identify a  particular Web Button
Set  Dbutton=description.Create
Dbutton("micclass").value="WebButton"
Dbutton("name").value="Sign in" 
'Descriptive object to identify  Web Text Box
Set Dedit=description.Create
Dedit("micclass").value="WebEdit"
Dedit("name").value="Email" 
'wait till browser loads
Browser(Dbrowser).Page(Dpage).Sync 
' Enter  Email id in Username Field
Browser(Dbrowser).Page(Dpage).WebEdit(Dedit).Set  "vb-excel.blogspot.in/" 
Dedit("name").value="Passwd" 
'Enter password in Passowrd Field
Browser(Dbrowser).Page(Dpage).WebEdit(Dedit).Set  "qtp" 
'Cick on the Sign In Button
Browser(Dbrowser).Page(Dpage).WebButton(Dbutton).Click


No comments:

Post a Comment