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

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

  • jo

    in flight reservation example,i recorded ‘inserting order’ and then faxed.stopped recording.in the script the order is 21.when i am playing,the order no.is changing to 22 and so on dynamically.what should i do to stop this.i want to see order no.22 and fax order no.22 when i play the record.

  • Hi Jo,
    You need to use Regular Expression to execute that script for fax oder no.22.

    Ex:Window(“Flight Reservation”).Dialog(“Fax Order No. 21″).ActiveX(“MaskEdBox”).Type “243546547486768″

    The part of the recorded script would be like the above. Right click on the Dialog(“Fax Order No. 21″). Goto Object Properties–text-Fax Order No. 21. click on Fax Order No. 21,click on the small button.
    There u change Fax Order No. 21 to Fax Order No.* and check the regular expression check box . One pop up would come ,click no. Later say ok . Now if u execute ,it works.
    Now ,u may get problem at date in the application. So again u can record and do the above steps for better option.

  • Kala

    How do i close the Flight Reservation Application using vbscript in QTP.

  • Hi Kala,

    If you want to close Flight Reservation Window,u can
    use the below code.

    Window(“text:=Flight Reservation”).Close

  • Kala

    Hi Admin,
    Do u know how to test a Windows Services?.

  • Hi,
    i don’t know that. But i can give one advise.
    If u search in google for that u may get the solution.

  • Leo

    hi,
    i in “Flight Reservation” need to fetch the value of order no and store it in to the excel sheet how can i get this.

  • satya

    hi i am new to qtp .function library is used to call functions right …can u tell me example for function library reg flight application.how do u create function library for flight app. and how to call that function…

  • Hi Satya,
    Function library contains the functions. And in qtp we call them for execution.
    If we want to create function library for flight reservation application,we need to use descriptive programming,because the objects which we are writing
    in function library should recognize from either object repository or through descriptive programming.

  • pls help me to write a script in automation relating to FSO and also the defenitions and functionality of DIM and SET.
    also i need some practical daily applicable examples for types and kinds and methods of testing(manual and automation)

  • How to get a value from listbox using array concept.

  • satish

    Pls if anyone can provide me with the script for searching the flight using date logic

  • Neerupama

    Hello Admin ,

    I have installed the QTP 11 with all plug-ins.
    I tried using the flight application using record and playback.
    QTP does not capture all events that is flight date and also flight application close.
    I have checked my settings and all.
    Kindly assist

    Regards
    Neeru.

  • Hi,
    You can uncheck the Web Add in before doing record and try. It works

  • sura

    Hi, Admin
    i cant open my Flight Reservation Application, it says “Bad Image”. Do u know how to fix this problem?

  • Kiran

    Hi ,
    Please tell me how to add web application(actiTIME)to object repository ?
    please reply me soon …Thanks in advance..

  • veena

    Hi
    I have a doubt ,how to verify that flyfroom combobox are in alphabetical order..
    i trieed by using getroproperty(“ll items”) to get all the items but i was not able to split and continue further ..please help
    Regards
    Veena

  • Can u please help me how to design framework for flight reservation application?

  • vijay

    Hi admin

    Here are the steps that i need to convert into automation script

    open fax order dialog box

    sign in signature box and enter fax number

    tick on “send sign with fax”

    and check whether the sign in the preview fax window is the same as the sign in previous window

    Can you please tell me how to do that?? (i have been told it involves analog recording and bmp checkpoint) however it must work even when i change the signature and rerun the test.

  • vaibhav bapar

    can any one tell me from where to download flight reservation application.

  • Hi Vaibhav,

    If you install QTP,automatically Flight Reservation Application also be installed.

  • ravi

    Hi,

    How to check the fax order dialog box information with fax preview dialog box information in flight reservation application.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>