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).
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("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
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.
Go to Resources->Recovery Scenario Manager...
Recovery Scenario Manager window opens
Click on "New Scenario" icon to open Recovery Scenario Wizard.
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:
msgbox "hello Function"
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.
'Returns a handle to a run-time object's window
'Assigning an object reference to a variable
Set pop_win=Window("hwnd:=" & win_handle)
'Printing that object's title
'Clicking OK button on that object.