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
Click on the new recovery scenario button
This opens up the recovery scenario wizard:
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.
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:
This is the initial information that it grabbed when I pointed to the pop-up window:
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)
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.
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.
This is what the code from my function looks like:
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.
I choose to add it to this script. And now it's part of our test.
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?