QTP Recovery Scenario
QuickTest Professional Recovery Scenarios are summarized in the below mentioned points with 3 "easy to understand" examples.
1)
With "Recovery Scenario Manager" you can
a) create and edit recovery files,
b) create and manage the recovery scenarios stored in those files.
2)
A unique icon corresponds to a recovery scenario that indicates its type.
3)
Each recovery scenario is represented by an icon that indicates its type.
4)
You are guided step-by-step, through the process of creating a recovery scenario by Recovery Scenario Wizard.
5)
You start by defining the trigger event. [4 trigger types are there Pop-up window, Object state, Test run error, Application crash]
Pop-up window :
QTP Recovery Scenario 1
NOTE: Below is just one of the many ways of creating a recovery scenario.
We get a pop-up window (like the one you see below) while opening some of the websites like www.rediff.com. In the example below we will make use of that pop-up dialog. We can use different Recovery Scenarios for different pop-up windows, but here I am just using one Pop-up window as an example.
I have divided this example into 3 parts (1. creating a test, 2. creating a function library and 3. creating a recovery scenario).
1.
Open QTP and Internet Explorer.
Click on Record in QTP in order to start recording.
In the address bar of IE type http://www.rediff.com
When rediff is open, type some text in the Search textbox e.g. 'I am doing a test on QTP'
Click on Search button
Browser("Browser").Page("Page").Sync
Browser("Browser").Navigate "http://www.rediff.com/"
wait(10)
Browser("Welcome to Rediff.com").Page("Welcome to Rediff.com").WebEdit("MT").Set "I am doing a test on qtp"
Browser("Welcome to Rediff.com").Page("Welcome to Rediff.com").WebButton("Search").Click
2.
Go to File->New->Function Library
A new Function Library will be open. Without writing anything in the Function Library (let it be empty), just Save it and close it.
We will create Recovery Function in accordance with the prototype syntax of the Pop-up window at the time of creating a Recovery Scenario.
3.
Go to Resources->Recovery Scenario Manager...
Recovery Scenario Manager window opens
Click on "New Scenario" icon to open Recovery Scenario Wizard.
Click Next.
From Select Trigger Event, choose Pop-up window. Click Next.
Now when the "Specify Pop-up Window Conditions" area is open, make sure the pop-up window is also open simultaneously with this
"Specify Pop-up Window Conditions" window, so that you can click on the hand icon and then click on pop-up window so as to fill the "Window title" and "Window text contains" fields. Click Next.
Recovery Operations area opens, Click Next.
Choose Recovery Operation as Function Call, click Next.
On the next screen, click on button on the right of "Function Library" dropdown to select the function library we created earlier.
Click "Define new function:" radio button and The function in the Function prototype will be:
Function RecoveryFunction1(Object)
msgbox "hello Function"
End Function
Click Next
In the Recovery Operation window uncheck "Add another recovery operation". Click Next.
In the Post-Recovery Test Run Options choose "Stop the test run" radio button. Click Next.
Give the Recovery Scenario a Name and Description and click Next
In the Completing the Recovery Scenario Wizard area check "Add scenario to current test" and click Finish.
In the Recovery Scenario Manager window you will see one scenario added in the scenarios area.
Click Close and save the Recovery Scenario.
Now Run the test. It should show message box with the message we wrote in function library while creating a Recovery Scenario.
In the second part of this example, instead of creating an empty function library we can write one function in it according to the appropriate prototype like the one below, which clicks the OK button on the Pop-up window.
Function Recovery_Example(Object)
'Returns a handle to a run-time object's window
win_handle=Object.GetROProperty("hwnd")
'Assigning an object reference to a variable
Set pop_win=Window("hwnd:=" & win_handle)
'Printing that object's title
Msgbox pop_win.GetROProperty("title")
'Clicking OK button on that object.
pop_win.WinButton("text:=OK").Click
End Function
Object state :
QTP Recovery Scenario 2
1)
This is an example of Object State trigger event.
Open QTP and Flight Reservation window.
Click Record in QTP in order to start recording.
Enter Date of Flight, Fly From, Fly To fields.
Click Flights... button. Flights Table opens. Click OK.
Enter Name and Click Insert Order.
After Insert Order is complete the Delete icon is enabled.
Now our Recovery scenario works if this delete icon is disabled (when its enabled property is False)
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 "sach"
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure "484190f7c6928cfbf4630e91eaf4d2901b3381e1"
Dialog("Login").WinEdit("Password:").Type micReturn
Window("Flight Reservation").WinObject("Date of Flight:").Type "090909"
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 "sach"
Window("Flight Reservation").WinButton("Insert Order").Click
Window("Flight Reservation").WinButton("Button_2").Click
Window("Flight Reservation").Dialog("Flight Reservations").WinButton("No").Click
Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"
2)
Go to File->New->Function Library
A new Function Library will be open. Without writing anything in the Function Library (let it be empty), just Save it and close it.
We will create Recovery Function in accordance with the prototype syntax of the Pop-up window at the time of creating a Recovery Scenario.
3)
Go to Resources->Recovery Scenario Manager...
Recovery Scenario Manager window opens
Click on "New Scenario" icon to open Recovery Scenario Wizard.
Click Next.
From Select Trigger Event, choose Object State. Click Next.
In Select Object area, click on hand and then click on the Delete icon on the Flight Reservation window.
Click OK in "Object Selection - Object State Trigger" window. Click Next.
Set Object properties and Values window opens. Click Add/Remove..button
In the Edit Properties window, check only window id and enabled and click OK.
Edit the enabled property to False. Click Next
Again click Next in Recovery Operations area.
Choose Recovery Operation as Function Call, click next.
On the next screen, click on button on the right of "Function Library" dropdown to select the function library we created earlier.
Click "Define new function:" radio button and The function in the Function prototype will be:
Function RecoveryFunction1(Object)
msgbox "hello Function"
End Function
Click Next
In the Recovery Operation window uncheck "Add another recovery operation". Click Next.
In the Post-Recovery Test Run Options choose "Stop the test run" radio button. Click Next.
Give the Recovery Scenario a Name and Description and click Next
In the Completing the Recovery Scenario Wizard area check "Add scenario to current test" and click Finish.
In the Recovery Scenario Manager window you will see one scenario added in the scenarios area.
Click Close and save the Recovery Scenario.
To see the recovery scenario working, try to run the test with lines 6 to 12 of the code in section 1 (line which types date to the line which clicks Insert Order button) commented.
Test run error :
QTP Recovery Scenario 3
1)
Make sure Flight Reservation window is open.
Fill Date of Flight, Fly From and Fly To fields.
Click Record in QTP in order to start recording.
Click on the Flights button in the Flight Reservation window.
When the Flights Table window opens click on OK.
Click stop in order to stop recording.
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
2)
Go to File->New->Function Library
A new Function Library will be open. Without writing anything in the Function Library (let it be empty), just Save it and close it.
We will create Recovery Function in accordance with the prototype syntax of the Pop-up window at the time of creating a Recovery Scenario.
3)
Go to Resources->Recovery Scenario Manager...
Recovery Scenario Manager window opens
Click on "New Scenario" icon to open Recovery Scenario Wizard.
Click Next.
From Select Trigger Event, choose Test run error. Click Next.
In "Select Test Run Error" area, choose "Object is disabled" from Error dropdown. Click Next.
Recovery Operations area opens, Click Next.
Choose Recovery Operation as Function Call, click next.
On the next screen, click on button on the right of "Function Library" dropdown to select the function library we created earlier.
Click "Define new function:" radio button and The function in the Function prototype will be:
Function RecoveryFunction1(Object)
msgbox "hello Function"
End Function
Click Next
In the Recovery Operation window uncheck "Add another recovery operation". Click Next.
In the Post-Recovery Test Run Options choose "Stop the test run" radio button. Click Next.
Give the Recovery Scenario a Name and Description and click Next
In Completing the Recovery Scenario Wizard area check "Add scenario to current test" and click Finish.
In the Recovery Scenario Manager window you will see one scenario added in the scenarios area.
Click Close and save the Recovery Scenario.
Now when you Run the test make sure in the Flight Reservation window you go to File->New Order, so as to empty all fields and disable Flights button to see if the Recovery Scenario is triggered when the object is disabled.
6)
After that you specify the recovery operation(s) [Recovery Operation can be Keyboard or mouse operation, Close application process, Function call, Restart Microsoft Windows]
When using Function call, Functions have to be defined using a prototype syntax, which is different for each trigger type.(See QTP User Guide.)
7)
Then you select a post-recovery test run operation. [Which can be Repeat current step and continue, Proceed to next step, Proceed to next action or component iteration, Proceed to next test iteration, Restart current test run, Stop the test run]
8)
The recovery file is saved in the specific location with the file extension .qrs.
9)
Properties for any defined recovery scenario can be viewed from Recovery Scenario Properties dialog box
10)
During the run session, QuickTest ignores deleted recovery scenario that is associated with a test or component.
11)
You can copy recovery scenarios from one recovery scenario file to another.
12)
The scenarios can be prioritized so that QuickTest applies the scenarios during the run session in a order of priority.
13)
Some or all of the scenarios can be disabled.
14)
Recovery Scenario(s) can be set as default for all new tests.
15)
Go to File > Settings, the Test Settings dialog box opens. Select the Recovery tab.
You can edit a recovery scenario file path by clicking the path once to highlight it, and then clicking it again to enter edit mode.
16)
In the Recovery tab itself you can define when the recovery mechanism is activated:
On every step.
On error
Never.
17)
You can use the Recovery object to control the recovery mechanism programmatically during the run session.
Saturday, September 27, 2008
QTP Recovery Scenario Examples
Labels:
QTP,
QTP Checkpoint,
QTP Help,
QTP Recovery Scenario Examples
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment