Parameterization:
Test the application with multiple set of data is called data driven testing.
using control structures: passing only values not text
dynamic data submission
DDT using external files (xl files, db files, flat files(notepad) )
Dim i
For i = 1 to 5 step 1
Window("Flight Reservation").Activate
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set i
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Next
Dim i
n = InputBox("enter record number: ")
For i = 1 to n step 1
Window("Flight Reservation").Activate
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set i
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Next
Parameterization:
'Environment Variables
Built-in Variables:
x=Environment.Value("OS")
msgbox x
x=Environment.Value ("OS")
msgbox x
y=Environment.Value("ProductDir")
msgbox y
z=Environment.Value("TestName")
msgbox z
User Defined Variables:
-----------------------
SystemUtil.Run Environment.Value("Path")
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set Environment.Value ("User_Name")
Dialog("Login").WinEdit("Password:").SetSecure Environment.Value ("Password")
Dialog("Login").WinButton("OK").Click
-----------------------------------------------------
Function Login()
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "asdf"
Dialog("Login").WinEdit("Password:").SetSecure "509deeb7c57fe0c263a243000443f8a68f771dd0"
Dialog("Login").WinButton("OK").Click
End Function
Function OpenOrder()
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "4"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
End Function
Function Logout()
Window("Flight Reservation").Activate
Window("Flight Reservation").Close
End Function
x=Datatable.Value("Key",dtGlobalSheet)
Select Case x
Case "L"
Call Login()
Case "O"
Call OpenOrder()
Case "X"
Call Logout()
Case else
msgbox "invalid key"
End Select
====================================================================
'Driver script
RepositoriesCollection.Add '
executefile '
x=Datatable.Value("Key",dtGlobalSheet)
Select Case x
Case "L"
Call Login()
Case "O"
Call OpenOrder()
Case "X"
Call Logout()
Case else
msgbox "invalid key"
End Select
'data driven testing using notepad
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile ("C:\OpenOrder.txt",1, true)
f.SkipLine
While f.AtEndOfStream <>true
s= f.ReadLine
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set s
wait(2)
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Wend
f.Close
Set fso = nothing
======================================
For i=1 to 6
Window("Flight Reservation").Activate
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set RandomNumber(1,6)
wait(2)
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Window("Flight Reservation").WinButton("Button").Click
Next
------------------------------------
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set DataTable("agentname",dtGlobalSheet)
Dialog("Login").WinEdit("Password:").SetSecure DataTable("password", dtGlobalSheet)
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
------------------------------------------
'data driven testing using notepad
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile ("C:\OpenOrder.txt",1, true)
f.SkipLine
While f.AtEndOfStream <>true
s= f.ReadLine
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set s
wait(2)
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Wend
f.Close
Set fso = nothing
===========
Open Order
5
2
8
9
4
Option Explicit
Dim fso, f, s, x
Set fso = CreateOBject("Scripting.FilesystemObject")
Set f=fso.OpenTextFile("c:\testdata.txt",1,true)
f.SkipLine
While f.AtEndOfLine ile
Wend
Function Login()
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "asdf"
Dialog("Login").WinEdit("Password:").SetSecure "509deeb7c57fe0c263a243000443f8a68f771dd0"
Dialog("Login").WinButton("OK").Click
End Function
Function OpenOrder()
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "4"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
End Function
Function Logout()
Window("Flight Reservation").Activate
Window("Flight Reservation").Close
End Function
x=Datatable.Value("Key",dtGlobalSheet)
Select Case x
Case "L"
Call Login()
Case "O"
Call OpenOrder()
Case "X"
Call Logout()
Case else
msgbox "invalid key"
End Select
====================================================================
'Driver script
RepositoriesCollection.Add '
executefile '
x=Datatable.Value("Key",dtGlobalSheet)
Select Case x
Case "L"
Call Login()
Case "O"
Call OpenOrder()
Case "X"
Call Logout()
Case else
msgbox "invalid key"
End Select
-----------------------------------------------------------------
DB Connection:
Create the db in sql server:
------------------------------
use mahesh
create table login(agentname varchar(15),
password varchar(15));
insert into login values ('abcr','mercury');
select *from login
==============================
Option Explicit
Dim rs, con
Set con = CreateObject("ADODB.Connection")
con.Open "Provider =sqloledb.1; server=localhost; uid=sa; pwd=sa; database=mahesh"
Set rs = CreateObject("ADODB.Recordset")
rs.Open "select *from login",con
rs.MoveFirst
Do while not rs.EOF
msgbox rs.Fields("agentname")
msgbox rs.Fields ("Password")
rs.MoveNext
Loop
Create the db in ms access:
------------------------------
create the database login.mdb in MSAccess 2007 with table name login saved in 2003 format
AgentName & Password for these fields give the data
Option Explicit
Dim rs, con
Set con = CreateObject("ADODB.Connection")
con.Open "Provider=microsoft.jet.oledb.4.0; data source=C:\login.mdb"
Set rs = CreateObject("ADODB.Recordset")
rs.Open "select *from login",con
rs.MoveFirst
Do while not rs.EOF
msgbox rs.Fields("AgentName")
msgbox rs.Fields ("Password")
rs.MoveNext
Loop
----------------------------------------------------------------
Test the application with multiple set of data is called data driven testing.
using control structures: passing only values not text
dynamic data submission
DDT using external files (xl files, db files, flat files(notepad) )
Dim i
For i = 1 to 5 step 1
Window("Flight Reservation").Activate
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set i
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Next
Dim i
n = InputBox("enter record number: ")
For i = 1 to n step 1
Window("Flight Reservation").Activate
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set i
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Next
Parameterization:
'Environment Variables
Built-in Variables:
x=Environment.Value("OS")
msgbox x
x=Environment.Value ("OS")
msgbox x
y=Environment.Value("ProductDir")
msgbox y
z=Environment.Value("TestName")
msgbox z
User Defined Variables:
-----------------------
SystemUtil.Run Environment.Value("Path")
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set Environment.Value ("User_Name")
Dialog("Login").WinEdit("Password:").SetSecure Environment.Value ("Password")
Dialog("Login").WinButton("OK").Click
-----------------------------------------------------
Function Login()
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "asdf"
Dialog("Login").WinEdit("Password:").SetSecure "509deeb7c57fe0c263a243000443f8a68f771dd0"
Dialog("Login").WinButton("OK").Click
End Function
Function OpenOrder()
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "4"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
End Function
Function Logout()
Window("Flight Reservation").Activate
Window("Flight Reservation").Close
End Function
x=Datatable.Value("Key",dtGlobalSheet)
Select Case x
Case "L"
Call Login()
Case "O"
Call OpenOrder()
Case "X"
Call Logout()
Case else
msgbox "invalid key"
End Select
====================================================================
'Driver script
RepositoriesCollection.Add '
executefile '
x=Datatable.Value("Key",dtGlobalSheet)
Select Case x
Case "L"
Call Login()
Case "O"
Call OpenOrder()
Case "X"
Call Logout()
Case else
msgbox "invalid key"
End Select
'data driven testing using notepad
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile ("C:\OpenOrder.txt",1, true)
f.SkipLine
While f.AtEndOfStream <>true
s= f.ReadLine
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set s
wait(2)
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Wend
f.Close
Set fso = nothing
======================================
For i=1 to 6
Window("Flight Reservation").Activate
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set RandomNumber(1,6)
wait(2)
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Window("Flight Reservation").WinButton("Button").Click
Next
------------------------------------
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set DataTable("agentname",dtGlobalSheet)
Dialog("Login").WinEdit("Password:").SetSecure DataTable("password", dtGlobalSheet)
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
------------------------------------------
'data driven testing using notepad
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile ("C:\OpenOrder.txt",1, true)
f.SkipLine
While f.AtEndOfStream <>true
s= f.ReadLine
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set s
wait(2)
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Wend
f.Close
Set fso = nothing
===========
Open Order
5
2
8
9
4
Option Explicit
Dim fso, f, s, x
Set fso = CreateOBject("Scripting.FilesystemObject")
Set f=fso.OpenTextFile("c:\testdata.txt",1,true)
f.SkipLine
While f.AtEndOfLine ile
Wend
Function Login()
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "asdf"
Dialog("Login").WinEdit("Password:").SetSecure "509deeb7c57fe0c263a243000443f8a68f771dd0"
Dialog("Login").WinButton("OK").Click
End Function
Function OpenOrder()
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "4"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
End Function
Function Logout()
Window("Flight Reservation").Activate
Window("Flight Reservation").Close
End Function
x=Datatable.Value("Key",dtGlobalSheet)
Select Case x
Case "L"
Call Login()
Case "O"
Call OpenOrder()
Case "X"
Call Logout()
Case else
msgbox "invalid key"
End Select
====================================================================
'Driver script
RepositoriesCollection.Add '
executefile '
x=Datatable.Value("Key",dtGlobalSheet)
Select Case x
Case "L"
Call Login()
Case "O"
Call OpenOrder()
Case "X"
Call Logout()
Case else
msgbox "invalid key"
End Select
-----------------------------------------------------------------
DB Connection:
Create the db in sql server:
------------------------------
use mahesh
create table login(agentname varchar(15),
password varchar(15));
insert into login values ('abcr','mercury');
select *from login
==============================
Option Explicit
Dim rs, con
Set con = CreateObject("ADODB.Connection")
con.Open "Provider =sqloledb.1; server=localhost; uid=sa; pwd=sa; database=mahesh"
Set rs = CreateObject("ADODB.Recordset")
rs.Open "select *from login",con
rs.MoveFirst
Do while not rs.EOF
msgbox rs.Fields("agentname")
msgbox rs.Fields ("Password")
rs.MoveNext
Loop
Create the db in ms access:
------------------------------
create the database login.mdb in MSAccess 2007 with table name login saved in 2003 format
AgentName & Password for these fields give the data
Option Explicit
Dim rs, con
Set con = CreateObject("ADODB.Connection")
con.Open "Provider=microsoft.jet.oledb.4.0; data source=C:\login.mdb"
Set rs = CreateObject("ADODB.Recordset")
rs.Open "select *from login",con
rs.MoveFirst
Do while not rs.EOF
msgbox rs.Fields("AgentName")
msgbox rs.Fields ("Password")
rs.MoveNext
Loop
----------------------------------------------------------------
No comments
Post a Comment