1. What is Descriptive Programming?
2. Why we are using Descriptive Programming in QTP?
No need to use Object Repository.
Execution is very faster than Object Repository.
3. Explain about Description Object?
4. How to write Descriptive Programming?
Two ways we can write the Descriptive Programming.
1. Static Programming
2. Dynamic Programming
4.1 Static Programming:
Again Two ways we can write the Descriptive Programming.
4.1.1. using Variable: assign the objects description to the Variable. That variable we can use in the Programme. That variables called Constant Variables.
Ex 1: Write a Descriptive Program for Flight Application Login Window and File>Open Order.
SystemUtil.Run "D:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe" Const ologin = "regexpwndtitle:=Login", oagentname = "attached text:=Agent Name:" Const opwd = "attached text:=Password:", ook = "text:=OK" Dialog(ologin).Activate Dialog(ologin).WinEdit(oagentname).Set "test" Dialog(ologin).WinEdit(opwd).SetSecure "4f02d6be35088fb2e778a58de61fd083e7a0522a" Dialog(ologin).WinButton(ook).Click Const ofrw = "regexpwndtitle:=Flight Reservation" Const oopenorderw = "regexpwndtitle:=Open Order" Const ocheckbox = "regexpwndtitle:=&Order No." Const oopenordereditbox = "abs_x:=269" Const ook2 = "abs_x:=338" Window(ofrw).Activate Window(ofrw).WinMenu("menuobjtype:=2").Select "File;Open Order..." Window(ofrw).Dialog(oopenorderw).WinCheckBox(ocheckbox).Set "ON" Window(ofrw).Dialog(oopenorderw).WinEdit(oopenordereditbox).Set "5" Window(ofrw).Dialog(oopenorderw).WinButton(ook2).Click Window(ofrw).Close |
4.1.2. Directly write the objects description in the Programming itself. Whatever objects description assign to the variables in the above example here Directly mention the objects description in the Programme.
Ex 1: Write a Descriptive Program for Flight Application Login Window and File>Open Order.
SystemUtil.Run "D:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe" Dialog("regexpwndtitle:=Login").Activate Dialog("regexpwndtitle:=Login").WinEdit("attached text:=Agent Name:").Set "test" Dialog("regexpwndtitle:=Login").WinEdit("attached text:=Password:").SetSecure "4f02d6be35088fb2e778a58de61fd083e7a0522a" Dialog("regexpwndtitle:=Login").WinButton("text:=OK").Click Window("regexpwndtitle:=Flight Reservation).Activate Window("regexpwndtitle:=Flight Reservation).WinMenu("menuobjtype:=2").Select "File;Open Order..." Window("regexpwndtitle:=Flight Reservation).Dialog("regexpwndtitle:=Open Order").WinCheckBox("regexpwndtitle:=&Order No.").Set "ON" Window("regexpwndtitle:=Flight Reservation).Dialog("regexpwndtitle:=Open Order").WinEdit("abs_x:=269").Set "5" Window("regexpwndtitle:=Flight Reservation).Dialog("regexpwndtitle:=Open Order").WinButton("abs_x:=338").Click Window("regexpwndtitle:=Flight Reservation).Close |
4.2 Dynamic Programming:
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("text:=Login").Activate
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set "abcd"
Dialog("text:=Login").WinEdit("attached text:=Password:").SetSecure "4ebc825c46d0b97f638a02d2733ba25883501cea"
Dialog("text:=Login").WinButton("text:=OK").Click
-----------------------------------------------------------------------------------------
If Not Dialog("text:=Login").Exist(3) Then
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
End If
Dialog("text:=Login").Activate
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set "abcd"
Dialog("text:=Login").WinEdit("attached text:=Password:").SetSecure "4ebc825c46d0b97f638a02d2733ba25883501cea"
Dialog("text:=Login").WinButton("text:=OK").Click
------------------------------------------------------------
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("text:=Login","index:=0").Activate
Dialog("text:=Login","index:=0").WinEdit("attached text:=Agent Name:").Set "abcd"
Dialog("text:=Login","index:=0").WinEdit("attached text:=Password:").SetSecure "4ebc825c46d0b97f638a02d2733ba25883501cea"
Dialog("text:=Login","index:=0").WinButton("text:=OK").Click
-----------------------------------------------------------------------------------
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Set x=Dialog("text:=Login","index:=0")
x.Activate
x.WinEdit("attached text:=Agent Name:").Set "abcd"
x.WinEdit("attached text:=Password:").SetSecure "4ebc825c46d0b97f638a02d2733ba25883501cea"
x.WinButton("text:=OK").Click
--------------------------------------------------------------------------------
Const Login="text:=Login", Agent="attached text:=Agent Name:", Password="attached text:=Password:"
Const Ok1="text:=OK", Ok2="width:=60", Ok3="height:=23"
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog(Login).Activate
Dialog(Login).WinEdit(Agent).Set "abcd"
Dialog(Login).WinEdit(Password).SetSecure "4ebc825c46d0b97f638a02d2733ba25883501cea"
Dialog(Login).WinButton(Ok1,Ok2,Ok3).Click
-----------------------------------------------------------------------------------------------------
'Create Collection Objects
Set Login=Description.Create
Set Agent=Description.Create
Set Password=Description.Create
Set Ok=Description.Create
'Enter Properties Information into Collection Objects
Login("text").value="Login"
Login("height").value=204
Login("enabled").value=True
Agent("attached text").value="Agent Name:"
Agent("window id").value=3001
Agent("x").value=20
Password("attached text").value="Password:"
Password("height").value=20
Password("visible").value=True
Ok("text").value="OK"
'Generate Statements using Collection Objects
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog(Login).Activate
Dialog(Login).WinEdit(Agent).Set "abcd"
Dialog(Login).WinEdit(Password).Set "mercury"
Dialog(Login).WinButton(Ok).Click
-----------------------------------------------------------------------------------------
Executefile "Obj.vbs"
'Generate Statements using Collection Objects
Set a=Dialog(Login)
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
a.Activate
a.WinEdit(Agent).Set "abcd"
a.WinEdit(Password).Set "mercury"
a.WinButton(Ok).Click
=============
static programming:
Const oLogin= "text:=Login"
Const oAgent = "attached text:=Agent Name: ","width:=320"
Const oPwd= "attached text:=Password:"
Const oOk = "text:=OK"
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog(oLogin).Activate
Dialog(oLogin).WinEdit(oAgent).Set "abcd"
Dialog(oLogin).WinEdit(oPwd).Set "mercury"
Dialog(oLogin).WinButton(oOk).Click
-------------------------
dynamic programming:
method2:
file-> settings-->resources->browse the .vbs file
Set oLogin =Description.Create
Set oAgent = Description.Create
Set oPwd = Description.Create
Set oOk=Description.Create
oLogin("text").Value = "Login"
oLogin("width").Value=320
oAgent("attached text").Value ="Agent Name:"
oPwd("attached text").Value ="Password:"
oOk("text").Value = "OK"
qtp main test:
Dialog(oLogin).Activate
Dialog(oLogin).WinEdit(oAgent).Set "abcd"
Dialog(oLogin).WinEdit(oPwd).Set "mercury"
Dialog(oLogin).WinButton(oOk).Click
=======================================================================
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
With Dialog("Login")
.Activate
.WinEdit("Agent Name:").Set "asdklf"
.WinEdit("Password:").SetSecure "509899fbe0af394d150a0653ed001e5f03af6fe5"
.WinButton("OK").Click
Window("Flight Reservation").Activate
Window("Flight Reservation").Close
End With
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
With Dialog("Login")
.Activate
.WinEdit("Agent Name:").Set "asdklf"
.WinEdit("Password:").SetSecure "mercury"
.WinButton("OK").Click
End With
'regexpwndtitle:=Login
'attached text:=Agent Name:
'attached text:=Password:
'regexpwndtitle:=OK
Const ologin = "regexpwndtitle:=Login", oagent = "attached text:=Agent Name:"
Const opwd = "attached text:=Password:", ook = "regexpwndtitle:=OK"
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog(ologin).Activate
Dialog(ologin).WinEdit(oagent).Set "abcd"
Dialog(ologin).WinEdit(opwd).Set "mercury"
Dialog(ologin).WinButton(ook).Click
Method 2:
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("regexpwndtitle:=Login").Activate
Dialog("regexpwndtitle:=Login").WinEdit("attached text:=Agent Name:").Set "abcd"
Dialog("regexpwndtitle:=Login").WinEdit("attached text:=Password:").Set "mercury"
Dialog("regexpwndtitle:=Login").WinButton("regexpwndtitle:=OK").Click
Method 3:
Set ologin = Description.Create()
Set oagent = Description.Create()
Set opwd = Description.Create()
Set ook = Description.Create()
ologin("text").Value = "Login"
ologin("regexpwndtitle").Value="Login"
oagent("attached text").Value = "Agent Name:"
opwd("attached text").Value = "Password:"
ook("text").Value = "OK"
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog(ologin).Activate
Dialog(ologin).WinEdit(oagent).Set "abcd"
Dialog(ologin).WinEdit(opwd).Set "mercury"
Dialog(ologin).WinButton(ook).Click
or
Note: without using tools options in qtp
Executefile "C:\Documents and Settings\Administrator\Desktop\desobjpro.vbs"
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog(ologin).Activate
Dialog(ologin).WinEdit(oagent).Set "abcd"
Dialog(ologin).WinEdit(opwd).Set "mercury"
Dialog(ologin).WinButton(ook).Click
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
With Dialog("Login")
.Activate
.WinEdit("Agent Name:").Set "asdklf"
.WinEdit("Password:").SetSecure "509899fbe0af394d150a0653ed001e5f03af6fe5"
.WinButton("OK").Click
Window("Flight Reservation").Activate
Window("Flight Reservation").Close
End With
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
With Dialog("Login")
.Activate
.WinEdit("Agent Name:").Set "asdklf"
.WinEdit("Password:").SetSecure "mercury"
.WinButton("OK").Click
End With
'regexpwndtitle:=Login
'attached text:=Agent Name:
'attached text:=Password:
'regexpwndtitle:=OK
Const ologin = "regexpwndtitle:=Login", oagent = "attached text:=Agent Name:"
Const opwd = "attached text:=Password:", ook = "regexpwndtitle:=OK"
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog(ologin).Activate
Dialog(ologin).WinEdit(oagent).Set "abcd"
Dialog(ologin).WinEdit(opwd).Set "mercury"
Dialog(ologin).WinButton(ook).Click
Method 2:
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("regexpwndtitle:=Login").Activate
Dialog("regexpwndtitle:=Login").WinEdit("attached text:=Agent Name:").Set "abcd"
Dialog("regexpwndtitle:=Login").WinEdit("attached text:=Password:").Set "mercury"
Dialog("regexpwndtitle:=Login").WinButton("regexpwndtitle:=OK").Click
Method 3:
Set ologin = Description.Create()
Set oagent = Description.Create()
Set opwd = Description.Create()
Set ook = Description.Create()
ologin("text").Value = "Login"
ologin("regexpwndtitle").Value="Login"
oagent("attached text").Value = "Agent Name:"
opwd("attached text").Value = "Password:"
ook("text").Value = "OK"
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog(ologin).Activate
Dialog(ologin).WinEdit(oagent).Set "abcd"
Dialog(ologin).WinEdit(opwd).Set "mercury"
Dialog(ologin).WinButton(ook).Click
or
Note: without using tools options in qtp
Executefile "C:\Documents and Settings\Administrator\Desktop\desobjpro.vbs"
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog(ologin).Activate
Dialog(ologin).WinEdit(oagent).Set "abcd"
Dialog(ologin).WinEdit(opwd).Set "mercury"
Dialog(ologin).WinButton(ook).Click
No comments
Post a Comment