Recovery Scenarios

Your test scripts will sometimes run into unexpected problems or errors as you run them. We will use recovery scenarios so that our scripts can "recover" from these errors and continue running the script.

Click on Resources -> Recovery Scenario Manager

alt text

Click on the new recovery scenario button

alt text

This opens up the recovery scenario wizard:

alt text

For this example, we will be putting in yesterday's date and this will cause a pop-up window stating that this is an incorrect date. So we want to select the pop-up window event at our trigger.

alt text

Then QTP gives us the option to point to the pop-up window. Click on the pointer and then click on the pop-up window that appears when you enter yesterday's date.

This is the pointer button:

alt text

This is the initial information that it grabbed when I pointed to the pop-up window:

alt text

But I changed it to be a regular expression so that is would work with any date no just 10/08/15. Regular expressions are great fun and can be very helpful. (See resources for more info about them)

alt text

Then we need to give our scenario some steps to help recover and continue. First we will need to hit Enter on the keyboard so the pop-up goes away.

alt text

Then we need this to erase out the bad date and enter in a good date. So I created a function which we will select.

alt text

This is what the code from my function looks like:

alt text

For the Post-Recovery, I will select "Re-run current step" because we fixed the date so we can re-run the step without any problems now.

Then give it a name and a description.

alt text

I choose to add it to this script. And now it's part of our test.

alt text

Exercise

Change one of the dates on your spreadsheet to a date before today's date. Then run your test sript. Does your test hit the recovery scenario? Instead of deleting the bad date and entering a new date, what else could you try to recover from this error?


Previous section: