Showing posts with label Dynamic Method. Show all posts
Showing posts with label Dynamic Method. Show all posts

Monday, August 13, 2012

Descriptive Programming (DP) in QTP


                         Descriptive Programming in QTP will be write in the case of the objects are not present in the Object Repository (OR), This method of programming reduces the time for automation testers in the time of CR in the project, Reduces the storage of space as compared to storage of objects, also avoids the modification of objects in the object repository.

There are two types of Programming in DP:

1. Static programming
2. Dynamic Programming

Static Programming:
 
 Syntax:

Window("Property1:=Value1","Property2:=Value2").Object("Property1:=Value1","Property2:=Value2"). Operation

The above syntax is the sample for static programming in qtp and below are the some of the Properties and Test Objects that we used in static method.




Web:

ClassName --> Micclass
Name --> WebEdit, Browser, Link, Image, WebCheckBox, webRadioGroup
URL --> Link, Image
href --> Link, Image

HWND:

alt --> Image
FileName --> WebCheckBox, WebRadioGroup, Image
Selection --> WebRadioGroup
Height
Width
x
y
abs_x
abs_y
Class --> WebElement
title --> page

Below i written a sample script for Yahoo login in static method:

Browser("Name:=Yahoo! Mail: The best web-based email!").Page("title:=Yahoo! Mail: The best web-based email!").WebEdit("Name:=login").Set"username"
Browser("Name:=Yahoo! Mail: The best web-based email!").Page("title:=Yahoo! Mail: The best web-based email!").WebEdit("Name:=Passwd").Set"passwd"
Browser("Name:=Yahoo! Mail: The best web-based email!").Page("title:=Yahoo! Mail: The best web-based email!").WebCheckBox("Name:=.persistent").Set"ON"
Browser("Name:=Yahoo! Mail: The best web-based email!").Page("title:=Yahoo! Mail: The best web-based email!").WebButton("Name:=Sign In").Click

Dynamic Programming:

Syntax:

1. SetObjname=Description.Create
2. ObjName("Prperty Name").Value=Property Value

Below i written a sample script for Google Search the keyword (QTP) in Dynamic method, save the below script as (filename.vbs) in any path in the Desktop:


Set Brw=Description.Create
Brw("Name").value="Google"
Set Pge=Description.Create
Pge("Title").value="Google"
Set txt=Description.Create
txt("Name").value="q"
Set btn=Description.Create
btn("Name").value="QTP"

Save the above script (filename.vbs) in any path in the Desktop:

Execute file "file.vbs"
Browser(brw).Page(pge).WebEdit(q).Set"Search"
Browser(brw).Page(pge).WebButton(btn).Click
Set brw=nothing
Set pge=nothing

While executing the above scripts in QTP (Execute file "file.vbs") script will refer the main script stored in the desktop as vbs file, the saved file can be use as a reusable framework and can be modify the objects as per the project business requirements when it's needed.

Below i written a sample scripts for (default available in QTP) Flight Reservation windows application in Dynamic method, save the below script as (flight.vbs) in any path in the Desktop:

Set lgn=Description.Create
lgn("text").value="Login"
Set uname=Description.Create
uname("attached text").value="Agent Name:"
Set pwd=Description.Create
pwd("attached text").value="Password:"
Set btn=Description.Create
btn("text").value="OK"
Set fr=Description.Create
fr("text").value="Flight Reservation"
Set dof=Description.Create
dof("attached text").value="Date of Flight:"
dof("nativeclass").value="MSMaskWndClass"
Set flyfrm=Description.Create
flyfrm("attached text").value="Fly From:"
Set flyto=Description.Create
flyto("attached text").value="Fly To:"
Set btn1=Description.Create
btn1("text").value="FLIGHT"
Set ft=Description.Create
ft("text").value="Flights Table"
Set list=Description.Create
list("attached text").value="From"
list("window id").value=2001
Set edit=Description.Create
edit("window id").value="1014"
Set radio=Description.Create()
radio("text").value="Business"
radio("regexpwndtitle").value="Business"
radio("windowstyle").value="1342177289"
Set orderbtn=Description.Create()
orderbtn("micclass").value="WinButton"
orderbtn("regexpwndtitle").value="&Insert Order"
Set updateorder=Description.Create()
updateorder("regexpwndtitle").value="&Update Order"

Save the above script (flight.vbs) in any path in the Desktop:


Executefile"C:\Documents and Settings\Bhaskar\Desktop\flight.vbs"
Dialog(lgn).winedit(uname).Set"admin"
Dialog(lgn).winedit(pwd).Set"mercury"
Dialog(lgn).winbutton(btn).Click
Window(fr).winobject(dof).type"08/24/12"
Window(fr).wincombobox(flyfrm).Select(1)
Window(fr).wincombobox(flyto).Select(2)
Window(fr).winbutton(btn1).Click
Window(fr).Dialog(ft).winlist(list).Select(2)
Window(fr).Dialog(ft).Winbutton(btn).Click
Window(fr).WinEdit(edit).Set"Antony"
WIndow(fr).WinRadioButton(radio).Set
Window(fr).WinButton(orderbtn).Click
Window(fr).WinButton(updateorder).Click

While executing the above scripts in QTP (Execute file "flight.vbs") script will refer the main script stored in the desktop as vbs file,