0% found this document useful (0 votes)
336 views

Flight Reservation Script

This document provides examples of testing a flight reservation application using Quick Test Professional (QTP). It includes examples of recording and playing back tests, descriptive programming, capturing screenshots, creating reusable actions, using regular expressions and parameterization, working with shared object repositories, using library functions, searching Google with different keywords, and storing test results in Excel.

Uploaded by

BalaSai Varma
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
336 views

Flight Reservation Script

This document provides examples of testing a flight reservation application using Quick Test Professional (QTP). It includes examples of recording and playing back tests, descriptive programming, capturing screenshots, creating reusable actions, using regular expressions and parameterization, working with shared object repositories, using library functions, searching Google with different keywords, and storing test results in Excel.

Uploaded by

BalaSai Varma
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Flight Reservation Application Testing Examples using QTP (Quick Test Professional)

1. Record and PlayBack (Login to Flight Reservation ,Book one ticket ,Insert Order , Send Fax Order and close) systemutil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe" Dialog("Login").Activate Dialog("Login").WinEdit("Agent Name:").Set "venkatesh" Dialog("Login").WinEdit("Agent Name:").Type micTab Dialog("Login").WinEdit("Password:").SetSecure "4c639147ce17debfa9a680adf3fb0a1f7b766d39" Dialog("Login").WinButton("OK").Click Window("Flight Reservation").ActiveX("MaskEdBox").Type "081310" Window("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt" Window("Flight Reservation").WinComboBox("Fly To:").Select "London" Window("Flight Reservation").WinEdit("Name:").Set "venkat" Window("Flight Reservation").WinButton("FLIGHT").Click Window("Flight Reservation").Dialog("Flights Table").WinList("From").Activate "13536 FRA 08:00 AM LON 08:45 AM SR $163.00" Window("Flight Reservation").WinEdit("Name:").Set "venkat" Window("Flight Reservation").WinButton("Insert Order").Click Window("Flight Reservation").WinMenu("Menu").Select "File;Fax Order..." ' used regular expression at the below Fax Order.Rht Click on Dialog and make it Fax Order No.* .And check the regular expression Window("Flight Reservation").Dialog("Fax Order No. 12").ActiveX("MaskEdBox").Type "0809972129" Window("Flight Reservation").Dialog("Fax Order No. 12").WinCheckBox("Send Signature with order").Set "ON" Window("Flight Reservation").Dialog("Fax Order No. 12").WinButton("Send").Click Window("Flight Reservation").Close 2 Descriptive Programming (Login to Flight Reservation) systemutil.run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe" Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set "venkatesh" Dialog("text:=Login").WinEdit("attached text:=Password:").SetSecure "4c63941e33c84ad39b70103970c7fe0f8e429f0f" Dialog("text:=Login").WinButton("text:=OK").Click Window("text:=Flight Reservation").Close 3.Capture Screen Shot (using CaptureBitmap) Login failed at Flight Reservation Application SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe" Dialog("Login").WinEdit("Agent Name:").Set "venkatesh" 'Desktop.CaptureBitmap "d:\login4.png" Dialog("Login").WinEdit("Password:").SetSecure "4c0616cda83a5c9f88633cdaff4c044c" Dialog("Login").WinButton("OK").Click

dialog("Login").Dialog("Flight Reservations").CaptureBitmap "d:\login.bmp" bexists=Dialog("Login").Dialog("Flight Reservations").Exist(2) If bexists Then smsg=Dialog("Login").Dialog("Flight Reservations").GetVisibleText reporter.ReportEvent micFail,"Login",smsg Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click Dialog("Login").WinButton("Cancel").Click exittest End If 4. Reusable Action (Flight Reservation Example) Action1: (Login with incorrect password and cacel) SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open" Dialog("Login").WinEdit("Agent Name:").Set "venkatesh" Dialog("Login").WinEdit("Password:").SetSecure "4c0616cda83a5c9f88633cdaff4c044c" Dialog("Login").WinButton("OK").Click bexists=Dialog("Login").Dialog("Flight Reservations").Exist(2) If bexists Then smsg=Dialog("Login").Dialog("Flight Reservations").GetVisibleText reporter.ReportEvent micFail,"Login",smsg Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click Dialog("Login").WinButton("Cancel").Click End If runaction "Action3",oneiteration Action2:
msgbox "welcome to action2"

Action3: (Reusable Action) used in Action1 : (Login with correct password) SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open" Dialog("Login").WinEdit("Agent Name:").Set "venkatesh" Dialog("Login").WinEdit("Password:").SetSecure "4c06513879e8c9aae96f878ebd40924cb403de52" Dialog("Login").WinEdit("Password:").Type micReturn Window("Flight Reservation").Close 5. Regular Expression and Parameterization (Login to Flight Reservation application, insert order and send fax information) (need to create fax_no in global sheet with fax numbers) ' Use of Regular Expressions and Parameterization ' Insert Order and Send Fax systemutil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe" Dialog("Login").Activate

Dialog("Login").WinEdit("Agent Name:").Set "venkatesh" Dialog("Login").WinEdit("Password:").SetSecure "4c63b0b0656069024c0d34dd2f5745a7b3780b8a" Dialog("Login").WinButton("OK").Click Window("Flight Reservation").ActiveX("MaskEdBox").Type "081410" Window("Flight Reservation").WinComboBox("Fly From:").Select "London" Window("Flight Reservation").WinComboBox("Fly To:").Select "Los Angeles" Window("Flight Reservation").WinButton("FLIGHT").Click Window("Flight Reservation").Dialog("Flights Table").WinList("From").Activate "19138 LON 08:00 AM LAX 08:45 AM AA $102.00" Window("Flight Reservation").WinEdit("Name:").Set "venky" Window("Flight Reservation").WinButton("Insert Order").Click Window("Flight Reservation").WinMenu("Menu").Select "File;Fax Order..." ' Rht click on the dialog below and make .* and check the regular expression Window("Flight Reservation").Dialog("Fax Order No. 21").ActiveX("MaskEdBox").Type DataTable("fax_no", dtGlobalSheet) Window("Flight Reservation").Dialog("Fax Order No. 21").WinButton("Send").Click Window("Flight Reservation").Close 6.Shared Object Repository a.(Record Login to Flight Reservation. Goto--Resouces--Object Repository(File--Export Local Objects).It will save as .tsr file) systemuti.run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe" Dialog("Login").WinEdit("Agent Name:").Set "venkatesh" Dialog("Login").WinEdit("Password:").SetSecure "4c63bd987f7ea31db67d4ec3760e762a901d3161" Dialog("Login").WinButton("OK").Click Window("Flight Reservation").Close
How to use it : Goto--Resources--Associate Repositories--Browse the .tsr file and add it.We can't edit this shared O.R. b. Goto--Resources--Object Repository Manager--(Objects--Add Objects).File--Save As.It will save as .tsr file 7. How to use Library Functions a. addition.vbs Function add a=20 b=30 c=a+b msgbox "The addition of a and b is : "&c End Function b. multiplication.vbs Function mul a=4 b=5 c=a*b msgbox "The multiplication of a and b is :"&c end function (File--Settings--Resources--Browse files)

8.Give different keywords at google and search (used descriptive programming and parameterization) Set ie=createobject("internetexplorer.application") ie.navigate("http://www.google.co.in/") ie.visible=true Browser("title:=Google").Page("title:=Google").WebEdit("name:=q").Set DataTable("search_keywords",dtGlobalSheet) Browser("title:=Google").Page("title:=Google").WebButton("value:=Google Search").Click Browser("opentitle:=Google").Close

9.Store Results in Excel Set xl= CreateObject("Excel.application") set wb=xl.workbooks.open("d:/sample2.xls") Set ws=wb.worksheets(1) a=15 b=20 If a>b Then ws.Cells(1,1).Value ="a is bigger" ws.Cells(1,2).value="PASS" Reporter.ReportEvent micDone,"a is bigger", a Else ws.Cells(1,1).Value = "b is bigger" ws.Cells(1,2).value = "FAIL" ws.cells(1,2).font.bold=true ws.cells(1,2).font.size=12 ws.Cells(1,2).font.colorindex=50 Reporter.ReportEvent micFail ,"b is bigger" , b End If wb.save wb.close Set ws=nothing Set wb=nothing Set xl=nothing

You might also like