How to use descriptive programming in qtp

Descriptive Programming:

QTP scripts can execute using Test scripts if the objects are present in the Object Repository. Descriptions of the Objects are created using Descriptive programming if Automation testers want to run an operation on an objects which is not display in the Object repository.





Drawbacks of Object Repository:

1.It takes lot of time for identify the objects ,when the object is changing dynamically.
2.If object repository size is increasing then the Test script execution speed will take more time.
3.To prepare Test scripts using object repository then testers should require build.

Descriptive programming means if we specify description of the objects in the Test scripts it self then that programming called as Descriptive programming in HP QTP. Using descriptive programming testers can execute test scripts without any object repository.Automation testers will execute Test scripts in QTP using descriptive programming.

Descriptive programming Advantages:

1.Fast Execution of Test script.
2.Easy to identify the objects.
3.We can prepare Test scripts without using build.

Descriptive programming Dis -Advantages:

It will take more time to prepare Test scripts using descriptive programming.

There are two types in Descriptive program,below are the types

1.Description properties and values in Test scripts
2.Description objects

Description properties and values in Test scripts:

Test script is developed using object properties and values of application in QTP.

Syntax:

Browser("p1:=value","p2:=value").page("p1:=value").object("p1:=value").operation/method

Examples:

Flight Application

Dialog("text:=Login").winedit("attachedtext:=Username").set "rajesh"
Dialog("text:=Login").WinEdit("attachedtext:=Password").set "xxxxxxxx"
Dialog("text:=Login").WinButton("text:=OK").Click
Window(text:=Flight Reservation).Close

Web Application

'Launch Gmail using internet explorer
Systemutil.Run "iexplore.exe","http:\\www.gmail.com" 

'Wait untill browser loads
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").Sync 

'Enter  Email id in Username Field of Gmail
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").
WebEdit("name:=Email").set "rajeshchev@gmail.com"

'Enter password in password Field of Gmail
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").
WebEdit("name:=password").Set "xxxxxxxxxx"

'Click on Sign in Button
Browser("title:=Gmail: Email from Google").Page("title:=Gmail: Email from Google").
WebButton("name:=Sign In").Click

Description Objects:

In order to create Descriptive programming we should create Description for Objects.

Syntax:
Set Object Name = Description.Create
Object Name("Property Name").Value="Property Value"

Examples:

Flight Reservation

'Create Description for Objects
Set dia = Description.Create
Set ana = Description.Create
Set pwd = Description.Create
Set but = Description.Create
Set win = Description.Create
'Create object Names with Properties and Values
dia("text").Value = "Login"
ana("attached text").Value = "Agent Name"
pwd("attached text").Value = "Password"
but("text").Value = "OK"
win("Flight Reservation").Value = "Flight Reservation"

'Launch Flight Application

Systemutil.Run "Path of the application"
Dialog(dia).WinEdit(ana).Set "rajesh"
Dialog(dia).WinEdit(pwd).Set "xxxxxxxx"
Dialog(dia).WinEdit(but).Click
Window(win).Close

Web Application:

Set bro = Description.Create
Set pge = Description.Create
Set sea = Description.Create
Set but = Description.Create
Set bro1 = Description.Create

bro(title).Value = "Google"
pge(title).Value = "Google"
sea(name).Value = "q"
but(name).Value = "Google search"
bro1(title).Value = "Google Search"

Browser(bro).Page(pge).WebEdit(sea).set "Google"
Browser(bro).Page(pge).WebButton(but).Click
Browser(bro1).CloseAllTabs


No comments:

Post a Comment