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
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.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("O rderNum").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 Files\HP\QuickTest Professional\samples\flight\app\flight4a.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
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 Settings\gcr\Desktop\Proj_Automation\Orginizer\Organizer.xls",1,3 DataTable.ImportSheet "C:\Documents and Settings\gcr\Desktop\Proj_Automation\Orginizer\Organizer.xls",2,4 DataTable.ImportSheet "C:\Documents and Settings\gcr\Desktop\Proj_Automation\Orginizer\Organizer.xls",3,5 DataTable.ImportSheet "C:\Documents and Settings\gcr\Desktop\Proj_Automation\TestData\data.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
Initialization Script:
Dim objQTP Set objQTP=CreateObject("QuickTest.Application") objQTP.Visible=True objQTP.Launch objQTP.Open "C:\Documents and Settings\gcr\Desktop\Proj_Automation\Drivers\Driver1" objQTP.Test.Run objQTP.Test.Close objQTP.Quit Set objQTP=Nothing
------------------------------------------------------------------
* GetWindow() Constants */ #define GW_HWNDFIRST 0 #define GW_HWNDLAST 1 #define GW_HWNDNEXT 2 #define GW_HWNDPREV 3 #define GW_OWNER 4 #define GW_CHILD 5 #define GW_ENABLEDPOPUP 6 #define GW_MAX 6 Example The following example retrieves a specific menu item's value in the Notepad application. ' Constant Values: Const MF_BYPOSITION = 1024 'API Functions Declarations Extern.Declare micHwnd,"GetMenu","user32.dll","GetMenu", micHwnd Extern.Declare micInteger,"GetMenuItemCount","user32.dll","GetMenuItemCount", micHwnd Extern.Declare micHwnd,"GetSubMenu","user32.dll","GetSubMenu", micHwnd, micInteger Extern.Declare micInteger,"GetMenuString","user32.dll","GetMenuString", micHwnd, micInteger, micString+micByRef, micInteger, micInteger Notepad.exe hwin = Window("Notepad").GetROProperty ("hwnd") ' Get Window's handle MsgBox hwin men_hwnd = Extern.GetMenu(hwin)' Get window's main menu's handle MsgBox men_hwnd Use API Functions item_cnt = Extern.GetMenuItemCount(men_hwnd) MsgBox item_cnt hSubm = Extern.GetSubMenu(men_hwnd,0) MsgBox hSubm rc = Extern.GetMenuString(hSubm, 0,value, 64 ,MF_BYPOSITION) MsgBox value 2 comments Posted by Sreekanth CR
' Parameters : 'strCode is a code to prefix the message with. 'strMessage is the message of file. '=========================================== Function WriteLog(strCode, strMessage) Dim objFS Dim objFile Dim objFolder Dim strFileName Set objFS = CreateObject("Scripting.FileSystemObject") If Not objFS.FolderExists(objFS.GetAbsolutePathName(".") & "\log") Then Set objFolder = objFS.CreateFolder(objFS.GetAbsolutePathName(".") & "\log") End If strFileName = objFS.GetAbsolutePathName(".") & "\log\" & year(date) & month(date) & day(date) & ".log" Set objFile = objFS.OpenTextFile(strFileName, 8, True) On Error Resume Next objFile.Write Date & ", " & Time & ", " & strCode & ", " & strMessage & vbcrlf ' disable the on error statement On Error GoTo 0 objFile.Close Set objFS = Nothing End Function 'Function Calling : call WriteLog("Fail","Invalid User Credentials")