Automation Framework

Hybrid Framework
Hybrid Framework: It is a mixture of two or more approaches
——–
To explain this Hybrid Framework, I have taken QTP sample Application (Flight Reservations)
————
Process Guidelines:
——————-
i) Creating the Folder structure
ii) Creating Automation Resources
Iii) Create Organizer spread sheet
Organizer provides instructions to the Driver
iv) Generating the driver Script (QTP Test)
(We associate all resources to the Driver
Driver executes tests based on Organizer spread sheet instructions)
v) Generate the initialization Script (AOM Script file)
It launches the QTP Tool, Calls the Driver Script
Driver executes tests one by one
It closes the QTP Tool
————————
Test Scenarios:
Click on this Excel sheet Image in order to get Big size and Clear Image
 Hybrid Framework Functions:
 ‘***********************************************
‘        Login Operation
‘***********************************************
Function Login(Agent, Password)
SystemUtil.Run “C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe”
Dialog(“Login”).Activate
Dialog(“Login”).WinEdit(“Agent Name:”).Set Agent
Dialog(“Login”).WinEdit(“Password:”).Set Password
Dialog(“Login”).WinButton(“OK”).Click
If Window(“Flight Reservation”).Exist(12) Then
‘Window(“Flight Reservation”).Close
Login=”Login Operation Sucessful”
‘Msgbox Login
Else
Systemutil.CloseDescendentProcesses
Login=”Login Failed”
‘Msgbox Login
End if
End Function
‘***********************************************
‘        Open Order
‘***********************************************
Function Open_Order(ord)
Window(“Flight Reservation”).Activate
Window(“Flight Reservation”).WinButton(“OpenOrder”).Click
Window(“Flight Reservation”).Dialog(“Open Order”).Activate
Window(“Flight Reservation”).Dialog(“Open Order”).WinCheckBox(“Order No.”).Set “ON”
Window(“Flight Reservation”).Dialog(“Open Order”).WinEdit(“OrderNum”).Set ord
Window(“Flight Reservation”).Dialog(“Open Order”).WinButton(“text:=OK”).Click
OrderNum=Window(“Flight Reservation”).WinEdit(“Order No:”).GetROProperty(“text”)
OrderNum=Cint(OrderNum)
If ord=OrderNum Then
Open_Order=ord&” Order Opened Sucessfully”
‘Msgbox Order_Number
Else
Open_Order=ord&” Order Not Opened”
‘Msgbox Order_Number
End If

End Function
‘***********************************************
‘        Update Order
‘***********************************************
Function Update_Order(Tickets)
Window(“Flight Reservation”).Activate
Window(“Flight Reservation”).WinButton(“OpenOrder”).Click
Window(“Flight Reservation”).Dialog(“Open Order”).WinCheckBox(“Order No.”).Set “ON”
Window(“Flight Reservation”).Dialog(“Open Order”).WinEdit(“OrderNum”).Set “5”
Window(“Flight Reservation”).Dialog(“Open Order”).WinButton(“text:=OK”).Click
Window(“Flight Reservation”).WinEdit(“Tickets:”).Set Tickets
Window(“Flight Reservation”).WinButton(“Update Order”).Click
Wait 10
Message=Window(“Flight Reservation”).ActiveX(“Threed Panel Control”).GetROProperty(“text”)
If  Message=”Update Done…” Then
Update_Order=”Order Updated Sucessfully”
‘Msgbox Update_Order
Else
Update_Order=”Order Not Updated”
‘Msgbox Update_Order
End If
End Function
‘***********************************************
‘        Close Application
‘***********************************************
Function Close_App()
If Window(“Flight Reservation”).Exist(3) Then
Window(“Flight Reservation”).Close
End If
End Function
‘***********************************************
‘        Login for Data Driven Testing
‘***********************************************
Function Login2(Agent, Password)
SystemUtil.Run “C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe”
Dialog(“Login”).Activate
Dialog(“Login”).WinEdit(“Agent Name:”).Set Agent
Dialog(“Login”).WinEdit(“Password:”).Set Password
Dialog(“Login”).WinButton(“OK”).Click
If Window(“Flight Reservation”).Exist(12) Then
Window(“Flight Reservation”).Close
Login2=”Login Operation Sucessful”
‘Msgbox Login
Else
Systemutil.CloseDescendentProcesses
Login2=”Login Failed”
‘Msgbox Login
End if
End Function
‘***********************************************
‘        Open Order for Data Driven Testing
‘***********************************************
Function Open_Order2(ord)
Window(“Flight Reservation”).Activate
Window(“Flight Reservation”).WinButton(“OpenOrder”).Click
Window(“Flight Reservation”).Dialog(“Open Order”).Activate
Window(“Flight Reservation”).Dialog(“Open Order”).WinCheckBox(“Order No.”).Set “ON”
Window(“Flight Reservation”).Dialog(“Open Order”).WinEdit(“OrderNum”).Set ord
Window(“Flight Reservation”).Dialog(“Open Order”).WinButton(“text:=OK”).Click
OrderNum=Window(“Flight Reservation”).WinEdit(“Order No:”).GetROProperty(“text”)
OrderNum=Cint(OrderNum)
If ord=OrderNum Then
Open_Order2=ord&” Order Opened Sucessfully”
‘Msgbox Order_Number
Else
Open_Order2=ord&” Order Not Opened”
‘Msgbox Order_Number
End If

End Function
‘***********************************************
‘        Update Order for Data Driven Testing
‘***********************************************
Function Update_Order2(Tickets)
Window(“Flight Reservation”).Activate
Window(“Flight Reservation”).WinButton(“OpenOrder”).Click
Window(“Flight Reservation”).Dialog(“Open Order”).WinCheckBox(“Order No.”).Set “ON”
Window(“Flight Reservation”).Dialog(“Open Order”).WinEdit(“OrderNum”).Set “5”
Window(“Flight Reservation”).Dialog(“Open Order”).WinButton(“text:=OK”).Click
Window(“Flight Reservation”).WinEdit(“Tickets:”).Set Tickets
Window(“Flight Reservation”).WinButton(“Update Order”).Click
Wait 10
Message=Window(“Flight Reservation”).ActiveX(“Threed Panel Control”).GetROProperty(“text”)
If  Message=”Update Done…” Then
Update_Order2=”Order Updated Sucessfully”
‘Msgbox Update_Order
Else
Update_Order2=”Order Not Updated”
‘Msgbox Update_Order
End If
End Function

Organizer Spread Sheet:
 I st Sheet “Module”

Click on this Excel sheet Image in order to get Big size and Clear Image

II nd Sheet “TestCase”

Click on this Excel sheet Image in order to get Big size and Clear Image 

 III rd Sheet “TestStep”

Click on this Excel sheet Image in order to get Big size and Clear Image
 

 Test Data:

Click on this Excel sheet Image in order to get Big size and Clear Image
 

Driver Script:
‘Adding sheets to Run-time data table
DataTable.AddSheet “Module”
DataTable.AddSheet “TestCase”
DataTable.AddSheet “TestStep”
DataTable.AddSheet “Login”
‘Importing data from External File
DataTable.ImportSheet “C:Documents and SettingsgcrDesktopProj_AutomationOrginizerOrganizer.xls”,1,3
DataTable.ImportSheet “C:Documents and SettingsgcrDesktopProj_AutomationOrginizerOrganizer.xls”,2,4
DataTable.ImportSheet “C:Documents and SettingsgcrDesktopProj_AutomationOrginizerOrganizer.xls”,3,5
DataTable.ImportSheet “C:Documents and SettingsgcrDesktopProj_AutomationTestDatadata.xls”,1,6
‘Capturing Executable Modules from Module Sheet
MRowCount=DataTable.GetSheet(“Module”).GetRowCount
For i=1 to MRowCount Step 1
          DataTable.SetCurrentRow(i)
          ModuleExe=DataTable(3,”Module”)
          If UCase(ModuleExe)=”Y” Then
                   ModuleId=DataTable(1,”Module”)
                   ‘Msgbox “ModuleId: ” & ModuleId
                   ‘           Capturing executable test cases under executable modules
                   TCRowCount=DataTable.GetSheet(“TestCase”).GetRowCount
                   For j=1 to TCRowCount Step 1
                             DataTable.SetCurrentRow(j)
                             TCCaseExe=DataTable(3,”TestCase”)
                             ModuleId2=DataTable(4,”TestCase”)
                             If UCase(TCCaseExe)=”Y” and ModuleId=ModuleId2 Then
                                      TestCaseId=DataTable(1,”TestCase”)
                                      ‘Msgbox TestCaseId
                                      ‘Capturing keywords for executable steps
                                      TSRowCount=DataTable.GetSheet(“TestStep”).GetRowCount
                                      For k=1 to TSRowCount Step 1
                                                DataTable.SetCurrentRow(k)
                                                TestCaseId2 = DataTable(5,”TestStep”)
                                                If TestCaseId=TestCaseId2 Then
                                                          keyword=DataTable(4,”TestStep”)
                                                          ‘msgbox keyword
                                                          Select Case keyword
                                                                   Case “ln”
                                                                                      Result=Login(“abcd”,”mercury”)
                                                                                      DataTable(7,”TestStep”)=Result
                                                                   Case “oo”
                                                                                      Result=Open_Order(5)
                                                                                       DataTable(7,”TestStep”)=Result
                                                                   Case “uo”
                                                                                      Result=Update_Order(5)
                                                                                      DataTable(7,”TestStep”)=Result
                                                                   Case “ca”
                                                                                      Close_App()
                                                                                      Case “lnd”
                                                                                                Rows=DataTable.GetSheet(“Login”).GetRowCount
    For m=1 to Rows Step 1
                                                                                                          DataTable.SetCurrentRow(m)
                                                                                                          Result=Login2(DataTable(1,”Login”),DataTable(2,”Login”))
                                                                                                          DataTable(3,”Login”)=Result
      Next
                                                                   Case “ood”
                                                                                                Rows=DataTable.GetSheet(“Login”).GetRowCount
    For n=1 to Rows Step 1
                                                                                                          DataTable.SetCurrentRow(n)
                                                                                                          Result=Open_Order2(DataTable(4,”Login”))
                                                                                                          DataTable(5,”Login”)=Result
          Next
          Case “uod”
                                                                                                Rows=DataTable.GetSheet(“Login”).GetRowCount
          For p=1 to Rows Step 1
                                                                                                          DataTable.SetCurrentRow(p)
                                                                                                          Result=Update_Order2(DataTable(6,”Login”))
                                                                                                          DataTable(7,”Login”)=Result
          Next
                                                          End Select
                                                End If
                                      Next
                             End If
         
                   Next
          End If
Next
DataTable.ExportSheet “C:Documents and SettingsgcrDesktopProj_AutomationTestResultResult1.xls”,”TestStep”
DataTable.ExportSheet “C:Documents and SettingsgcrDesktopProj_AutomationTestResultResult1.xls”,”Login”
Initialization Script:
Dim objQTP
Set objQTP=CreateObject(“QuickTest.Application”)
objQTP.Visible=True
objQTP.Launch
objQTP.Open “C:Documents and SettingsgcrDesktopProj_AutomationDriversDriver1″
objQTP.Test.Run
objQTP.Test.Close
objQTP.Quit
Set objQTP=Nothing
——————————————————————

Hybrid Framework using Keyword Driven and Data Driven Approches
 

 

 

Comments