Tuesday, September 25, 2007

Example of Synchronization

Make sure that only QTP and Sample Flight application are open.

Click on Record. When we click on Record, "Record and Run Settings" window opens up. Go to "Windows Applications" tab and choose first option "Record and run test on any open windows based application." and click on ok.

Enter the Date of flight as tommorrows date.
In Fly From choose Denver.
In Fly To Choose Frankfurt.
Click on Flights... button which is on the
R.H.S of the Fly To combo box.

Flights Table window open up. Let the
first option remains selected in that and just click on ok. It will
automatically fill some of the fields.

Enter your name in the Name field.

Click on Insert Order and let it complete uptill 100% untill you see the 'Insert Done...' text.

Go to Insert (menu)-> Synchronisation Point. QTP will be minimized and cursor will take the shape of a hand.

Click on that 'Insert Done...' text in the Flight application.

'Object Selection - Synchronization Point' window will open with 'ActiveX: Threed Panel Control.' selected.

Click Ok.

'Add Synchronization Point' window will open. Choose Property name as 'text' and Property value as "Insert Done..." (Don't forget to put those 3 dots, and double quotation marks e.g. " in the Property value text box.)
Click Ok.

In Flight application go to File (menu)-> New Order.

Click Stop in order to stop the recording.

This whole process will add WaitProperty.

The code in the Expert view looks like this:

Window("Flight Reservation").ActiveX("MaskEdBox").Click 1,9
Window("Flight Reservation").ActiveX("MaskEdBox").Type "092407"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Frankfurt"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "axc"

Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").ActiveX("Threed Panel Control").WaitProperty "text", "Insert Done...", 10000
Window("Flight Reservation").WinButton("Button").Click

I have modified the above script a little bit to capture
the WaitProperty value. WaitProperty Waits until the particular object property attain the specified value or exceeds the specified timeout before continuing to the next step.

Reporter is an Object used for sending info to test results and it uses ReportEvent method to accomplish this.

ReportEvent method sends the results to the result window. For more info on these plase see QTP help.

Window("Flight Reservation").ActiveX("MaskEdBox").Click 1,9
Window("Flight Reservation").ActiveX("MaskEdBox").Type "092407"
Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Frankfurt"
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set "axc"
Window("Flight Reservation").WinButton("Insert Order").Click
rc=Window("Flight Reservation").ActiveX("Threed Panel Control").WaitProperty ("text", "Insert Done...", 10000)
If rc=true Then
reporter.ReportEvent micPass,"sync on Insert Done...", "Property of text is true"
End If
msgbox rc
Window("Flight Reservation").WinButton("Button").Click