qtp/uft hybrid framework

Click here to load reader

Post on 02-Jun-2015

713 views

Category:

Software

0 download

Embed Size (px)

DESCRIPTION

QTP/UFT Hybrid Framework

TRANSCRIPT

  • 1. Test AutomationHybrid FrameworkHybrid Framework: It is a mixture of two or more approachesProcess Guidelines:i) Creating the Folder structureii) Creating Automation Resources (Library Files, Repository etc.)Iii) Create Organizer spread sheet (Organizer provides instructions to the Driver)iv) Generating the driver Script (QTP Test)v) Generate the initialization Script (AOM Script file)Folder Structure

2. Automation Resources:Test Scenarios:Hybrid Framework Functions:'***********************************************' Login Operation'***********************************************Function Login(Agent, Password)Systemutil.run"C:Program Files (x86)HPUnif ied FunctionalTestingsamplesflightappflight4a.exe"Dialog("Login").WinEdit("Agent Name:").Set Agent 3. Dialog("Login").WinEdit("Password:").Set PasswordDialog("Login").WinButton("OK").ClickIf Window("Flight Reservation").exist(10) Then'Systemutil.CloseDescendentProcessesLogin="Login Succesful"Else'Systemutil.CloseDescendentProcessesLogin= "Login Failed"End IfEnd Function'***********************************************' Login for Data Driven Testing'***********************************************Function Login2(Agent, Password)Systemutil.run"C:Program Files (x86)HPUnif ied FunctionalTestingsamplesflightappflight4a.exe"Dialog("Login").WinEdit("Agent Name:").Set AgentDialog("Login").WinEdit("Password:").Set PasswordDialog("Login").WinButton("OK").ClickIf Window("Flight Reservation").exist(10) ThenSystemutil.CloseDescendentProcessesLogin2="Login Succesful"ElseSystemutil.CloseDescendentProcessesLogin2= "Login Failed"End IfEnd Function'***********************************************' Open Order'***********************************************Function Open_Order(ord) 4. 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 OrdWindow("Flight Reservation").Dialog("Open Order").WinButton("OK").ClickOrderNum=Window("Flight Reservation").WinEdit("Order No:").GetROProperty("text")OrderNum=Cint(OrderNum)If Ord=OrderNum ThenOpen_Order=ord&" Order Opened Sucessfully"ElseOpen_Order=ord&" Order Not Opened"End ifEnd Function'***********************************************' Open Order for Data Driven Testing'***********************************************Function Open_Order2(Ord)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 OrdWindow("Flight Reservation").Dialog("Open Order").WinButton("OK").ClickOrderNum=Window("Flight Reservation").WinEdit("Order No:").GetROProperty("text")OrderNum=Cint(OrderNum)If Ord=OrderNum ThenOpen_Order2=ord&" Order Opened Sucessfully"ElseOpen_Order2=ord&" Order Not Opened" 5. End ifEnd Function'***********************************************' Update Order'***********************************************Function Update_Order(Tickets)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 "5"Window("Flight Reservation").Dialog("Open Order").WinButton("OK").ClickWindow("Flight Reservation").WinEdit("Tickets:").Set Ticketswait(5)Window("Flight Reservation").WinButton("Update Order").Clickwait(15)message= Window("Flight Reservation").ActiveX("Threed PanelControl").GetROProperty("text ")If message="Update Done..." ThenUpdate_Order="Update is done successfully"ElseUpdate_Order="Update failed"End IfEnd Function'***********************************************' Update Order for Data Driven Testing'***********************************************Function Update_Order2(Tickets)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 "5"Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click 6. Window("Flight Reservation").WinEdit("Tickets:").Set Ticketswait(3)Window("Flight Reservation").WinButton("Update Order").Clickwait(10)message= Window("Flight Reservation").ActiveX("Threed PanelControl").GetROProperty("text ")If message="Update Done..." ThenUpdate_Order2="Update is done successfully"ElseUpdate_Order2="Update failed"End IfEnd Function'***********************************************' Close Application'***********************************************Function Close_App()If window("Flight Reservation").exist(5) ThenWindow("Flight Reservation").CloseEnd IfSystemutil.CloseDescendentProcessesEnd FunctionOrganizer Spread Sheet:I st Sheet "Module" 7. II nd Sheet "TestCase" 8. III rd Sheet "TestStep" 9. Test Data: 10. Driver Script:Executefile "E:OtherTrainingQTPTestsHybrid-FrameworkLibrariesFR_Func_Library.vbs"'Adding sheets to Run-time data tableDataTable.AddSheet "Module"DataTable.AddSheet "TestCase"DataTable.AddSheet "TestStep"DataTable.AddSheet "Login"'Importing data from External FileDataTable.ImportSheet "E:OtherTrainingQTPTestsHybrid-FrameworkOrganizer.xls",1,3DataTable.ImportSheet "E:OtherTrainingQTPTestsHybrid-FrameworkOrganizer.xls",2,4 11. DataTable.ImportSheet "E:OtherTrainingQTPTestsHybrid-FrameworkOrganizer.xls",3,5DataTable.ImportSheet "E:OtherTrainingQTPTestsHybrid-Frameworkdata.xls",1,6'Capturing Executable Modules from Module SheetMRowCount=DataTable.GetSheet("Module").GetRowCountFor i=1 to MRowCount Step 1DataTable.SetCurrentRow(i)ModuleExe=DataTable(3,"Module")If UCase(ModuleExe)="Y" ThenModuleId=DataTable(1,"Module")'Msgbox "ModuleId: " & ModuleId'Capturing executable test cases under executable modulesTCRowCount=DataTable.GetSheet("TestCase").GetRowCountFor j=1 to TCRowCount Step 1DataTable.SetCurrentRow(j)TCCaseExe=DataTable(3,"TestCase")ModuleId2=DataTable(4,"TestCase")If UCase(TCCaseExe)="Y" and ModuleId=ModuleId2 ThenTestCaseId=DataTable(1,"TestCase")'Msgbox TestCaseId'Capturing keywords for executable stepsTSRowCount=DataTable.GetSheet("TestStep").GetRowCountFor k=1 to TSRowCount Step 1DataTable.SetCurrentRow(k)TestCaseId2 = DataTable(5,"TestStep")If TestCaseId=TestCaseId2 Thenkeyword=DataTable(4,"TestStep")'msgbox keywordSelect Case keywordCase "ln"Result=Login("abcd","mercury")DataTable(7,"TestStep")=ResultCase "oo"Result=Open_Order(5)DataTable(7,"TestStep")=Result 12. Case "uo"Result=Update_Order(RandomNumber(1,9))DataTable(7,"TestStep")=ResultCase "ca"Close_App()Case "lnd"Rows=DataTable.GetSheet("Login").GetRowCountFor m=1 to Rows Step 1DataTable.SetCurrentRow(m)Result=Login2(DataTable(1,"Login"),DataTable(2,"Login"))DataTable(3,"Login")=ResultNextCase "ood"Rows=DataTable.GetSheet("Login").GetRowCountFor n=1 to Rows Step 1DataTable.SetCurrentRow(n)Result=Open_Order2(DataTable(4,"Login"))DataTable(5,"Login")=ResultNextCase "uod"Rows=DataTable.GetSheet("Login").GetRowCountFor p=1 to Rows Step 1DataTable.SetCurrentRow(p)Result=Update_Order2(DataTable(6,"Login"))DataTable(7,"Login")=Result 13. NextEnd SelectEnd IfNextEnd IfNextEnd IfNextDataTable.ExportSheet "E:OtherTrainingQTPTestsHybrid-FrameworkResult1.xls","TestStep"DataTable.ExportSheet "E:OtherTrainingQTPTestsHybrid-FrameworkResult1.xls","Login"Initialization Script:Dim objQTPSet objQTP=CreateObject("QuickTest.Application")objQTP.Visible=TrueobjQTP.LaunchobjQTP.Open "C:Documents and SettingsgcrDesktopProj_AutomationDriversDriver1"objQTP.Test.RunobjQTP.Test.CloseobjQTP.QuitSet objQTP=Nothing

View more