Professional Documents
Culture Documents
Workshop
Flight Reservation Application
Using QTP
By
Suresh Babu B
Mind Q Systems
Automation Scenarios in Flight Reservation Application
1. Agent Login
2. Insert Order
3. Open Order
4. Update Order
5. Fax order
6. Delete Order
Exercise:
1. Prepare a test for Agent Login
2. Prepare a test for Insert Order
3. Prepare a test for Open Order
4 Prepare a test for Update Order
5. Prepare a test for Fax Order
6. Prepare a test for Delete Order
7. Prepare Keyword driven test.
Note:
1. Create an Excel file with 2 sheets titled Test Cases and Test Steps
to store test cases and test steps in the given format in Solutions section.
2. Associate the Environment Variables File to the Keyword Driven Test
4. Associate Function Library File to store all functions and procedures and
associate it to keyword-driven Test.
Solution:
1. Create an Excel file with 2 Sheets titled “Test Cases” and “Test Steps” and specify the
following.
Test Cases
Tcid Testcase Desc Execute Results
TC001 Check Agent Login with valid inputs Y
TC002 Check Insert Order with valid inputs Y
TC003 Check pen Order with valid inputs Y
TC004 Check Update Order with valid inputs Y
TC005 Check Fax Order with valid inputs Y
TC006 Check Delete Order Y
Test Steps
Tcid Step id Step Desc Results Keyword
TC001 Step 1 Activate FR Application LaunchApp
Enter valid Agnet Name,Valid password and click
TC001 Step 2 Ok AgentLogin
TC001 Step 3 Close the FR Application CloseApp
TC002 Step 1 Activate FR Application LaunchApp
TC002 Step 2 Login as Agent AgentLogin
Enter all mandatory fields with valid inputs and
TC002 Step 3 click Insert Order NewOrder
TC002 Step 4 Close the FR Application CloseApp
TC003 Step 1 Activate FR Application LaunchApp
TC003 Step 2 Login as Agent AgentLogin
Click Open Order,Enter a Order No and check the
TC003 Step 3 data OpenOrder
TC003 Step 4 Close the FR Application CloseApp
TC004 Step 1 Activate FR Application LaunchApp
TC004 Step 2 Login as Agent AgentLogin
TC004 Step 3 Open an Order OpenOrder
Modify necessary fields with valid inputs and click
TC004 Step 4 Update UpdateOrder
TC004 Step 5 Close the FR Application CloseApp
TC005 Step 1 Activate FR Application LaunchApp
TC005 Step 2 Login as Agent AgentLogin
TC005 Step 3 Open an Order OpenOrder
Go to File select Fax order, enter fax no and click
TC005 Step 4 Send FaxOrder
TC005 Step 5 Close the FR Application CloseApp
TC006 Step 1 Activate FR Application LaunchApp
TC006 Step 2 Login as Agent AgentLogin
TC006 Step 3 Open an Order OpenOrder
TC006 Step 4 Click Delete Order DeleteOrder
TC006 Step 5 Close the FR Application CloseApp
2. Create an Environment Variable File (.xml)
<Environment>
<Variable>
<Name>AppPath</Name>
<Value>C:\Program Files\HP\QuickTest
Professional\samples\flight\app\flight4a.exe</Value>
</Variable>
<Variable>
<Name>DateOfFly</Name>
<Value>090909</Value>
</Variable>
<Variable>
<Name>FlyFrom</Name>
<Value>London</Value>
</Variable>
<Variable>
<Name>FlyTo</Name>
<Value>Paris</Value>
</Variable>
<Variable>
<Name>Ono</Name>
<Value>12</Value>
</Variable>
<Variable>
<Name>PName</Name>
<Value>Richards</Value>
</Variable>
<Variable>
<Name>Pwd</Name>
<Value>mercury</Value>
</Variable>
<Variable>
<Name>Uid</Name>
<Value>Mindq</Value>
</Variable>
<Variable>
<Name>UpdTkts</Name>
<Value>3</Value>
</Variable>
<Variable>
<Name>FaxNo</Name>
<Value>1111111111</Value>
</Variable>
</Environment>
Function OpenApp(AppPath)
invokeapplication AppPath
If Dialog("Login").Exist(10) Then
OpenApp="Pass"
Else
OpenApp="Fail"
End If
End Function
Function Login(uid,pwd)
Dialog("Login").WinEdit("Password:").Set pwd
Dialog("Login").WinButton("OK").Click
Login="Pass"
Else
Login="Fail"
End If
End Function
Function CloseApp()
Window("Flight Reservation").Close
CloseApp="Pass"
Else
CloseApp="Fail"
End If
End Function
Function InsertOrder(DateOfFly,FlyFrom,FlyTo,PName)
Window("Flight Reservation").WinButton("New").Click
Window("Flight Reservation").WinButton("FLIGHT").Click
InsertOrder="Pass"
Else
InsertOrder="Fail"
End If
End Function
Function OpenOrder(ono)
Window("Flight Reservation").WinButton("Open").Click
OpenOrder="Pass"
Else
OpenOrder="Fail"
End If
End Function
Function UpdateOrder(ono,Tkts)
UpdateOrder="Pass"
Else
UpdateOrder="Fail"
End If
End Function
Function FaxOrder(ono,Faxno)
FaxOrder="Pass"
Else
FaxOrder="Fail"
End If
End Function
Function DeleteOrder(ono)
DeleteOrder="Pass"
Else
DeleteOrder="Fail"
End If
End Function
4. Prepare the Keyword-Driven Test
Dim StrAppPath,StrUid,StrPwd,DtDateOfFly,StrFlyFrom,StrFlyTo,StrPName
Dim intOno,intFaxNo,intTkts
Dim TCCount,Tcid,TcExeFlg,TSCount,TSTCid,Keyword,Res
Environment.LoadFromFile "e:\fr\Environment\fr.xml"
StrAppPath=Environment("AppPath")
StrUid=Environment("Uid")
StrPwd=Environment("Pwd")
DtDateOfFly=Environment("DateOfFly")
StrFlyFrom=Environment("FlyFrom")
StrFlyTo=Environment("FlyTo")
StrPName=Environment("PName")
intOno=Environment("Ono")
intFaxNo=Environment("FaxNo")
intTkts=Environment("UpdTkts")
Datatable.AddSheet "TestCases"
Datatable.AddSheet "TestSteps"
Datatable.ImportSheet "e:\fr\keyword.xls","TestCases","TestCases"
Datatable.ImportSheet "e:\fr\keyword.xls","TestSteps","TestSteps"
TCCount=Datatable.GetSheet("TestCases").GetRowCount
Datatable.GetSheet("TestCases").SetCurrentRow(i)
Tcid=Datatable("Tcid","TestCases")
TcExeFlg=Datatable("Execute","TestCases")
If UCase(TcExeFlg)="Y" Then
TSCount=Datatable.GetSheet("TestSteps").GetRowCount
TSTCid=Datatable("Tcid","TestSteps")
If TSTCid=Tcid Then
Keyword=Datatable("Keyword","TestSteps")
Case "LaunchApp"
Res=OpenApp(StrAppPath)
Case "AgentLogin"
Res=Login(StrUid,StrPwd)
Case "CloseApp"
Res=CloseApp()
Case "NewOrder"
Res=InsertOrder(DtDateOfFly,StrFlyFrom,StrFlyTo,StrPName)
Case "OpenOrder"
Res=OpenOrder(intOno)
Case "UpdateOrder"
Res=UpdateOrder(intOno,intTkts)
Case "FaxOrder"
Res=FaxOrder(intono,intfaxNo)
Case "DeleteOrder"
Res=Deleteorder(intOno)
End Select
Datatable("Results","TestSteps")=Res
If Datatable("Results","TestCases")<>"Fail" Then
Datatable("Results","TestCases")=Res
End If
End If
Next
Else
DataTable("Results","TestCases")="Blocked"
End If
Next
Datatable.ExportSheet "e:\fr\keywordresults.xls","TestCases"
Datatable.ExportSheet "e:\fr\keywordresults.xls","TestSteps"