Automation Scenarios in Flight Reservation Application
1. Agent Log
2. Insert Orde
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
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
3. Associate an Object Repository File that contains all objects to 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
|
Tcid
|
Step id
|
Step Desc
|
Results
|
Keyword
|
TC001
|
Step 1
|
Activate FR Application
|
LaunchApp
| |
TC001
|
Step 2
|
Enter valid Agnet Name,Valid password and click Ok
|
AgentLogin
| |
TC001
|
Step 3
|
Close the FR Application
|
CloseApp
| |
TC002
|
Step 1
|
Activate FR Application
|
LaunchApp
| |
TC002
|
Step 2
|
Login as Agent
|
AgentLogin
| |
TC002
|
Step 3
|
Enter all mandatory fields with valid inputs and 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
| |
TC003
|
Step 3
|
Click Open Order,Enter a Order No and check the 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
| |
TC004
|
Step 4
|
Modify necessary fields with valid inputs and click 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
| |
TC005
|
Step 4
|
Go to File select Fax order, enter fax no and click 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
|
Public StrApppath,StrAgName,StrPword,DtDateOfFly,StrFlyFrom,StrFlyTo,StrPName
Public intTkts,StrClassOfFly,intOno,intUpdTkts,intFaxNo
StrApppath="C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
StrAgName="AHAMAD"
StrPword="ahamadqtp"
DtDateOfFly="101010"
StrFlyFrom="Paris"
StrFlyTo="London"
StrPName="ahamad"
intTkts=2
intOno=32
intUpdTkts=3
StrClassOfFly="B"
intfaxNo=1111111111
=======================================================================
3. Create a Function Library File
Function OpenApp (AppPath)
Invoke application AppPath
If Dialog ("Login").Exist (10) Then
Reporter.ReportEvent micPass,"Application Launch”, “Application Launched successfully"
OpenApp="Pass"
Else
Reporter.ReportEvent micFail,"Application Launch”,” Application Launch failed"
OpenApp="Fail"
End If
End Function
======================================================================
Function Login(uid,pwd)
Dialog("Login").WinEdit("Agent Name:").Set uid
Dialog("Login").WinEdit("Password:").Set pwd
Dialog("Login").WinButton("OK").Click
If Window("Flight Reservation").Exist(10) Then
Reporter.ReportEvent micPass ,"Agent Login","Agent Login Successful"
Login="Pass"
Else
Reporter.ReportEvent micFail ,"Agent Login","Agent Login failed for valid inputs"
Login="Fail"
End If
End Function
=======================================================================
Function CloseApp()
Window("Flight Reservation").Close
If not Window("Flight Reservation").Exist(1) Then
Reporter.ReportEvent micPass ,"Application Close","Application Closed Successfully"
CloseApp="Pass"
Else
Reporter.ReportEvent micFail ,"Application Close","Applciation Close Failed"
CloseApp="Fail"
End If
End Function
=====================================================================
Function InsertOrder(DateOfFly,FlyFrom,FlyTo,PName)
Window("Flight Reservation").WinButton("New").Click
Window("Flight Reservation").ActiveX("DateOfFly").type DateOfFly
Window("Flight Reservation").WinComboBox("Fly From:").Select FlyFrom
Window("Flight Reservation").WinComboBox("Fly To:").Select FlyTo
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select(0)
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set PName
Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").ActiveX("MsgControl").WaitProperty "text","Insert Done...",10000
If Window("Flight Reservation").ActiveX("MsgControl").GetROProperty("text")="Insert Done..." Then
Reporter.ReportEvent micPass ,"Insert Order","New Order Created Successfully"
InsertOrder="Pass"
Else
Reporter.ReportEvent micFail ,"Insert Order","New order Creation failed"
InsertOrder="Fail"
End If
End Function
=====================================================================
Function OpenOrder(ono)
Window("Flight Reservation").WinButton("Open").Click
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Click
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set ono
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
If Cint(trim(window("Flight Reservation").WinEdit("Order No:").GetROProperty("text")))=ono Then
Reporter.ReportEvent micPass ,"Open Order","Open Order Test Passed"
OpenOrder="Pass"
Else
Reporter.ReportEvent micFail ,"Open Order","Open Order Test Failed"
OpenOrder="Fail"
End If
End Function
=====================================================================
Function UpdateOrder(ono,Tkts)
Window("Flight Reservation").WinEdit("Tickets:").Set tkts
Window("Flight Reservation").WinButton("Update Order").Click
Window("Flight Reservation").ActiveX("MsgControl").WaitProperty "text","Update Done...",10000
If Window("Flight Reservation").ActiveX("MsgControl").GetROProperty("text")="Update Done..." Then
Reporter.ReportEvent micPass ,"Update Order","Order Updated Successfully"
UpdateOrder="Pass"
Else
Reporter.ReportEvent micFail ,"Update Order","Update Order Failed"
UpdateOrder="Fail"
End If
End Function
===================================================================
Function FaxOrder(ono,Faxno)
Window("Flight Reservation").WinMenu("Menu").Select "File;Fax Order..."
Window("Flight Reservation").Dialog("Fax Order No. 1").ActiveX("FaxNo").Type "1111111111"
Window("Flight Reservation").Dialog("Fax Order No. 1").WinButton("Send").Click
Window("Flight Reservation").ActiveX("MsgControl").WaitProperty "text","Fax Sent Successfully...",10000
If window("Flight Reservation").ActiveX("MsgControl").GetROProperty("text")="Fax Sent Successfully..." Then
Reporter.ReportEvent micPass ,"Fax Order","Fax Sent Successfully"
FaxOrder="Pass"
Else
Reporter.ReportEvent micFail ,"Fax Order", "Fax Sending failed"
FaxOrder="Fail"
End If
End Function
====================================================================
Function DeleteOrder(ono)
Window("Flight Reservation").WinButton("Delete Order").Click
Window("Flight Reservation").Dialog("Flight Reservations").WinButton("Yes").Click
Window("Flight Reservation").ActiveX("MsgControl").WaitProperty "text","Delete Done...",10000
If Window("Flight Reservation").ActiveX("MsgControl").GetROProperty("text")="Delete Done..." Then
Reporter.ReportEvent micPass ,"Delete Order","Order Deleted Successfully"
DeleteOrder="Pass"
Else
Reporter.ReportEvent micFail ,"Delete Order","Delete Order Failed"
DeleteOrder="Fail"
End If
End Function
=======================================================================
4. Prepare the Keyword-Driven Test
Option Explicit
Dim TCCount,i,Tcid,TcExeFlg,TsCount,TsTcid,Keyword,Res,j
Datatable.AddSheet "TestCases"
Datatable.AddSheet "TestSteps"
Datatable.ImportSheet "d:\Flight\Keyword.xls","TestCases","TestCases"
Datatable.ImportSheet "d:\Flight\Keyword.xls","TestSteps","TestSteps"
TCCount=Datatable.GetSheet("TestCases").GetRowCount
For i=1 to TCCount
Datatable.GetSheet("TestCases").SetCurrentRow(i)
Tcid=Datatable("Tcid","TestCases")
TcExeFlg=Datatable("Execute","TestCases")
If UCase(TcExeFlg)="Y" Then
TsCount=Datatable.GetSheet("TestSteps").GetRowCount
For j=1 to TsCount
Datatable.GetSheet("TestSteps").SetCurrentRow(j)
TsTcid=Datatable("Tcid","TestSteps")
If Tcid=TsTcid Then
Keyword=Datatable("Keyword","TestSteps")
Select Case Keyword
Case "LaunchApp"
Res=openApp(StrApppath)
Case "AgentLogin"
Res=Login(StrAgName,StrPword)
Case "CloseApp"
Res=CloseApp()
Case "NewOrder"
Res=InsertOrder(DtDateofFly,StrFlyFrom,StrFlyTo,StrPName)
Case "OpenOrder"
Res=OpenOrder(intOno)
Case "UpdateOrder"
Res=UpdateOrder(intOno,intUpdTkts)
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 "d:\Flight\KeywordResults.xls","TestCases"
Datatable.ExportSheet "d:\Flight\KeywordResults.xls","TestSteps"
Hi Ahamad,
ReplyDeleteThis script for keyword driven is good example. but still dnt answer some of my questions.
As per my knowlwdge -
"The Keyword-driven Framework is an application independent framework that performs all possible actions and verifications on an object. Hence, the code for the same object can be used across different applications."
So how can u apply this above mentioned script to different application?
Thanks Ahamad for your reply and knowledge sharing. :)
ReplyDeleteGood Job Dude....
ReplyDelete