What are the use of Recovery Scenario in UFT?

Recovery Scenario Manager

Table of Contents

Share and Enjoy !

Recovery Scenario in UFT

Recovery Scenario is one integrated option for UFT or QTP professionals. Any unwanted behavior of the application which can not be handled by coding can be handled by the Recovery scenario. It is best and effective when we go to uninterrupted run and night mode execution. We can do Error handling in UFT  via recovery scenario.

So Recovery Scenario governs the UFT or QTP to recover from unexpected events and errors that occur in our testing environment during a run session. In the below section we will look what is recovery scenario?  what is the recovery scenario in uft/qtp with example.

Ads code goes here

The recovery scenario can be divided into the following parts:

  1. Definition of Recovery and how to use it?
  2. When to use the Recovery scenario?
  3. Definition of different Recovery scenarios.
  4. Recovery Scenario Wizard
  5. Managing different Recovery scenarios.
  6. Setup Recovery scenarios for our tests.
  7. How to control the recovery scenario using code?

Definition of Recovery and how to use it?

Unexpected events, errors, and application crashes during a run session can disrupt our run session and distort results. This is a problem particularly when running tests or components unattended mode – the test or component is suspended until we perform the operation needed to recover. This section elaborates on how to create a recovery scenario in uft/qtp.

The quick process is as follows:

  1. We can ceate a new Recovery Scenario.
  2. We can specify the trigger event.
  3. We can specify the corrective actions.
  4. We can specify the post recovery operations
  5. We can cross verify the summary.
  6. We can add the recovery scenario(s) to our test or component.

Recovery Scenario Manager provides a wizard that guides us through the process of defining a recovery scenario a definition of an unexpected event and the operation (s) necessary to cover the run session.

For example, we can instruct QuickTestProfessional or UFT to detect a Printer out of the paper message and recover the run session by clicking the OK button to close the message to continue the test or component.

UFT Recovery Scenario Manager
UFT Recovery Scenario Manager

The Recovery Manager can handle the below-written failures by recovery Wizard. Post creating a recovery we need to attach the recovery to the test. The below section will talk about the recovery scenario wizard in uft

  • Trigger Event: Options  – The event that interrupts our run session. For example, a window that may pop up on the screen, or a QuickTest/UFT run error.

1. pop Window
2. object State
3. Test run error
4. Application crash

  • Specify the recovery operation-Recovery Operation (s) – The operation (s) that need to be performed in order to continue running the test or component. For example, clicking an OK button in a popup window, or restarting Microsoft Windows.
  • Define post-recovery operations: The instructions on how QuickTest/Unified Functional Test will proceed once the Recovery operations have been performed, and from which point in the test or component from the beginning, or skip a step entirely and continue once the recovery should continue if at all.

For example, we may want to restart a test or component from the beginning or skip a step and continue with the next step in the test or component.

1. Repeat the current step and continue
2. Proceed to the next step
3. Proceed to the next iteration
4. Proceed to next component iteration
5. Restart the current test
6. Stop the test run

We need to provide the name and description of the recovery scenario. Also, we need to mention if the recovery is for the entire test or specific to the action. However, we can create a general recovery scenario for our test.

Step level Recovery: The recovery will be activated after every step.
Error level Recovery: The recovery will be activated after it encounters an error.
If we select the option “Never”, recovery will not be activated.

Where Recovery Scenarios got saved?

Recovery scenarios are saved in recovery scenario files. A recovery scenario is a logical collection of recovery scenarios which are grouped according to our need.

To instruct UFT/QTP to perform a recovery scenario during a run session, we need to associate the recovery options with the test or components. A test or a component may have any number of recovery scenarios associated with it.

We can prioritize the scenario associated with our tests or components to make sure that trigger events are recognized and handled in the required order.

When we run a test or component for which we have defined recovery scenarios and an error occurs, UFT/QTP looks for the defined trigger event/events that caused the error. If a trigger event has occurred, QTP/UFT performs the corresponding recovery and post-recovery operations.

We can control and activate recovery scenarios during the run session by inserting Recovery statements into our code of tests or components. So recoveries can be enabled, disabled, added or deleted via recovery tab under test settings.

If we choose On error in the Activate recovery scenarios box in the Recovery tab of the Test Settings dialog box or Business Component Settings dialog box, the recovery mechanism does not handle triggers that occur in the last step of a test or component.

If we choose this option and need to recover from an unexpected event or error that may occur in the last step of a test or component, we can accomplish this by adding an extra step to the end of our test or test component.

When to use the Recovery scenario?

Recovery Scenario should only be used when we do not expect some other thing to happen in between the test execution. So all pop-ups should not be handled with the Recovery Scenario.

If we can predict that a certain event may happen at a specific point in our test or component, it is highly recommended to handle that event directly within our test or component by adding optional steps to handle the situation. We can also use if statements too!. Moreover, all predictable states should be handled in our code and we should not depend on the recovery to handle this.

Below are the scenarios that should be handled by code:

  • A popup that displays the confirmation dialog from an application.
  • A popup displays statements if we do some wrong operation.
  • A popup when we edit a file system and try to save the same.
  • A popup that is part of the functionality of the application.

I am not saying these conditions can not be handled via the Recovery Scenario. Yes, we can. But it takes time for the Recovery manager for handling operations. So our test execution will be longer than expected.

Handling an event directly within our test enables us to handle errors more specifically than recovery scenarios, which by nature are designed to handle a more generic set of unpredictable events. It also enables us to control the timing of the corrective operation with minimal resource usage and maximum performance.

By default, recovery operations are activated after a step returns an error, which can potentially fail several steps after the one that actually caused the error. The alternative, checking for trigger events after every step, may slow performance.

We should use recovery scenarios only for unpredictable events, or events that we cannot synchronize with a specific step in our test or component.

For example, a recovery scenario can handle a printer error by clicking the default button in the Printer Error message box. we cannot handle this error directly in our test or component since we cannot know at what points the network will return the printer error.

we could try to handle this event in our test or component, by adding an If statement immediately after the step that sent a file to the printer, but if the network takes time to return the printer error, our test or component may have progressed several steps before the error is displayed. Hence, for this type of event, only a recovery scenario can handle.

Definition of different Recovery scenarios

The Recovery Scenario Manager dialog box enables us to create recovery scenarios and save them in recovery files. We create recovery scenarios using the Recovery Scenario wizard which leads us through the process of defining each of the stages of the recovery scenario.

After this, the recovery scenarios can be placed in a recovery file and can be associated with our tests or components.

How to create a Recovery Scenario using Wizard

We save our recovery scenarios in a recovery file. A recovery file is a collection and a convenient way to organize and store more than one recovery scenario at the same location. We can create a new recovery file or edit an existing recovery scenario.

To create a recovery file we have to follow the below path:

Resources | Recovery Scenario Manager

This will open the recovery scenario manager:

Recovery-Scenario-Manager-in-UFT
Recovery-Scenario-Manager-in-UFT

By default, the recovery scenario dialog box opens with a new recovery file. We can either use the new file or click on the Open button to edit some of the existing recovery files.

Just in case we have recently created a recovery file, we can click on the small arrow to open the recently created recovery.

The recovery scenario manager dialog provides us the ability to create and edit recovery files. It also enables us to create and manage recovery scenarios. The Recovery Scenario Manager dialog box displays the followings

  • The name of the currently opened recovery file
  • The list of scenarios saved in the recovery files
  • The description of each scenario.

Understanding the Recovery Scenario Wizard

The Recovery Scenario Wizard leads us, a step-by-step, through the process of creating a recovery scenario. The Recovery Scenario Wizard contains five main steps:

  • Defining the trigger event that interrupts the run session.
  • Specifying the recovery operation (s) required to continue.
  • Choosing a post-recovery test run operation.
  • Specifying a name and description for the recovery scenario.
  • Specifying whether to associate the recovery scenario to the current test and/or to all new tests.

We open the Recovery Scenario Wizard upon clicking the New Scenario button in the Recovery Scenario Manager dialog box.

Recovery-scenario-Welcome Screen
Recovery-scenario-Welcome Screen

Once we click on the button we will get Welcome to the Recovery Scenario Wizard screen. This screen provides all general information about the different options in the Recovery Scenario Wizard. It also provides an overview of the stages involved in defining a recovery scenario.

READ  How To Work With Automation Object Model In UFT?

We will click on Next to select the Trigger Event Screen.

Select Trigger Event Screen

The Select Trigger Event screen provides us the option to define the event type that triggers the recovery scenario. It also advocates how UFT/QTP will recognize the event.

Select Trigger Event in UFT
Select Trigger Event in UFT

Various options are listed below:

  • Pop-up Window
  • Object state
  • Test run error
  • Application crash

Let us understand each option:

Pop-up Window

UFT/QTP detects a pop-up window and identifies it according to the window title and text content in it.

For example, a message box may open during a run session indicating that the printer is out of paper. UFT/QTP detects this window and activates a pre-defined recovery scenario to continue its execution.

Object state

UFT/QTP identifies a specific test object state and detects it according to its property values and the property values of all its ancestors. (Test objects are identified by its property values but by its class). It is often referred as the object state recovery scenario in UFT/QTP.

For example, a specific button in a dialog box may be disabled when the specific process is open. UFT/QTP can detect the object property state of the button. Then UFT/QTP activates the recovery scenario and handles this exception and UFT/QTP can continue its execution.

Test run error

UFT/QTP can detect a run error and identifies it by a failed returned value from a method.

For example, UFT/QTP may not be able to identify the menu item specified in the method argument as the menu item is not available at a specific point during the run session. UFT/QTP can identify this run error and activates a pre-defined recovery scenario to continue its execution.

Application crash

UFT/QTP can detect an application crash and identifies it according to a pre-defined list of applications.

For example, a secondary application may crash when a particular ceratin step is performed during the execution window. We need to be sure that the run session does not fail due to this crash. It may indicate a different problem in our application

UFT/QTP can detect this application crash and activates the pre-defined recovery scenario to continue its execution.

The set of recovery options is performed for each occurrence of the trigger event criteria. Assume that we have defined a specific object state and two objects match this particular state, the set of reply operation is performed two times. (once for each object that matches the specified state).

The recovery mechanism does not handle triggers that occur in the last step of a test or component. If we need to recover from an unexpected event or error that may occur in the last step of a test or component, we can accomplish this by adding an extra step to the end of our test or component.

Whichever option we select, we need to click on the Next button to configure the recovery.

How to specify the popup window conditions screen?

If we choose a pop- up window in the Select Trigger Event Screen, the specify pop window conditions screen opens.

The window will look like below:

Specify-pop up window Screen
Specify-pop up window Screen

Click the pointing hand and then click on the pop-up window to capture the window title and text content of the window.

Special Tips:
We need to click and hold the CTRL key to change the window focus or perform operations such as a right-click or mouse over to display a context menu.

Note

Pressing the CTRL key does not enable us to select an application from the Windows taskbar, therefore we must make sure that the window we want to access is maximized or activated.

We can choose whether you want to identify the pop – up window according to its Window title and/ or Window text. We can also use regular expressions in the window title or textual content by selecting the relevant Regular expression checkbox and then enter the regular expression in the relevant location.

How to work with Select-Object Screen

In case, if we choose an Object State trigger in the Select Trigger Event screen the select object screen opens.

The screen will look like below:

Object-State-Select-Object
Object-State-Select-Object

We need to click on the pointing hand and then click on the object whose properties we want to specify.

Special Tips:
We need to click and hold the CTRL key to change the window focus or perform operations such as a right-click or mouse over to display a context menu.

Note

Pressing the CTRL key does not enable us to select an application from the Windows taskbar, therefore we must make sure that the window we want to access is maximized or activated.

If the location we click is associated with more than one object, the Object Selection state trigger dialog box opens.

The window will look like below:

Object Selection-Object State Trigger
Object Selection-Object State Trigger

We need to select whose properties we want to specify and click on OK.  The selected object and its parents are displayed in the Select-Object Screen.

Note

The hierarchical object selection tree also provides us to select an object that UFT/QTP will not ordinarily record(a nonparent object), like a web table.

How to set Object Properties and Values Screen?

After we select the object whose properties we want to specify in the select object, the Set Object properties and values screen opens.
The screen will look like below:

set Object Propertise and Values
set Object Properties and Values

For each object in the hierarchy, in the Edit property value box, we can modify the property values used to identify the object. We can also click on the Add/Remove button to add or remove object properties from the list of property values to check.

Note

An object is only identified by UFT/QTP by its property values, not by its classes.

We can also select Regular expression checkbox if we want to use regular expression in the property value.

How to work on Test Run Error Screen?

If we have chosen a Test run error trigger in the Select Trigger Event screen, the Select Test Error screen opens.

The Screen will look like below:

Select Test Run Error Screen
Select Test Run Error Screen

In the error list, we can choose one of the following run errors that we want to use as a trigger. The dropdown is having various definitions of errors. The drop-down options are as below:

  • Any error –  Any error code that is returned by a step while UFT/QTP is executing a script.
  • Item in list or menu is not unique – – This error occurs when more than one item in the list, menu, or tree has the name specified in the method argument.
  • Item in list or menu not found — This error occurs when UFT/QTP cannot identify the list, menu, or tree item specified in the method argument. This may be due to the fact that the item is not currently available or that its name has changed.
  • More than one object responds to the physical description – This error occurs when more than one object in our application has the same property values as those specified in the test object description for the object specified in the step.
  • Object is disabled – This error occurs when UFT/QTP cannot perform the step because the object specified in the step is currently disabled.
  • Object not found – This error occurs when no object within the specified parent object matches the test object description for the object.
  • Object not visible– This error occurs when UFT/QTP cannot perform orm the the step because the object specified in the step is not currently visible on the screen.

How to Define Application crash options? Or How to work with Select Process Screen?

If we have choosen an Application crash  in the trigger in the Select Trigger Event screen, the select process screen opens.

The screen looks like below:

Select Process Screen in UFT Recovery Scenario
Select Process Screen in UFT Recovery Scenario

The Running processes list displays all application processes that are currently running in the system. The Processes list displays the application processes that will trigger the recovery very scenario if they crash.

We can add application processes to the Processes list by typing them in the Processes list or by selecting them from the Running processes list.

To add a process from the Running processes list, we need to double – click a process in the Running processes list or select it and click the Add button. We can also select multiple processes using Windows multiple selection techniques (CTRL and SHIFT keys).

To add a process directly to the Processes list, we need to click the Add New Process button to enter the name of any process we want to add to the list.

To remove a process from the Processes list, we need to select the process name click the Remove Process button. We can modify the name of a process by selecting it in the Processes list and clicking the process name to edit it.

For all the above cases, we need to click on the Next button to get the Recovery Operations Screen.

How to work on the Recovery Operations Screen?

The Recovery Operations screen provides us the ability to manage the collection of recovery operations in the recovery scenario. Recovery operations are operations that UFT/QTP performs sequentially when it recognizes the trigger event.

The Recovery Operations screen looks like-

Recovery Operations Screen in Recovery Scenario
Recovery Operations Screen in Recovery Scenario

We should define at least one recovery operation. To define a recovery operation and add it to the Recovery operations list, click Next to continue to the Recovery Operation screen.

If we define two or more recovery operations, we can select a recovery operation and use the Move Up or Move Down buttons to change the order in which UFT/QTP performs the recovery operations. we can also select a recovery operation and click the Remove button to delete a recovery operation from the recovery scenario.

Note: If we define a Restart Microsoft Windows recovery operation, it is always inserted as the last recovery operation, and we cannot change its position in the list.

After we have defined at least one recovery operation, the Add another recovery operation checkbox is displayed. We need to select the checkbox and click Next to define another recovery operation

Multiple Recovery Operations Screen in Recovery Scenario
Multiple Recovery Operations Screen in Recovery Scenario

We can clear the checkbox and click Next to continue to the Post – Recovery Test Run Option screen.

How to Work with Recovery Operation Screen?

The Recovery Operation screen provides us the ability to specify the operation (s) UFT/QTP performs after detecting the trigger event.

The Recovery Operation Screen looks like:

Recovery Operation Screen in UFT Recovery
Recovery Operation Screen in UFT Recovery

The options are as follows:

  • Keyboard or mouse operation – UFT/QTP simulates a click on a button in a window or press a keyboard key.
  • Close application process –  UFT/QTP closes specified processes.
  • Function call -UFT/QTP calls a VBScript function. The function can reside in script, VbScript library(.vbs file) or QuickTest functional library ( .qfl file).
  • Restart Microsoft Windows – UFT/QTP restarts Microsoft Windows.

If we use the Restart Microsoft Windows recovery operation, we must ensure that any test or component associated with this recovery scenario is saved before we run it. we must also configure the computer on which the test or component is run to auto-login on restart.

We can select any of the options and click on the Next button to proceed with the selective option screen.

How to work on Recovery Operation – Click Button or Press Key Screen?

Once we chose a keyboard or mouse operation recovery operation in the Recovery Operation screen, the Recovery Operation – Click Button or Press Key screen opens.

The screen will look like

Recovery Operation- Click Button or Press Key
Recovery Operation- Click Button or Press Key

Let us understand the various options in this screen as described below:

  • Click Default button/ Press the ENTER key– This option tells UFT/QTP to click the default button or press the ENTER key in the displayed window when the trigger occurs.
  • Click Cancel button/ Press ESCAPE key –  This option tells UFT/QTP to click on the Cancel button or press the ESCAPE key in the displayed window the trigger occurs.
  • Click button with label –  This option tells UFT/QTP to click on the button with the specified label in the displayed window when the trigger occurs. If we opt to choose this option, we need to click on the pointing hand button and then click on the trigger window.
READ  Learn File System Object(FSO) in UFT or QTP or VBScript Free

We can hold the CTRL key to change the window focus or perform operations such as right-click or mouseover to display a context menu.  Pressing the CTRL key does not enable us to select an application from the Windows taskbar, therefore we must make sure that the window we want to access is maximized first.

All button labels in the selected window are displayed in the list box. We need to select the required button from the list.

  • Press key or key combination-This option tells UFT/QTP to press the specified key or key combination in the displayed window when the trigger occurs. If we select this option, click in the edit box and then press the key or key combination on our keyboard that we want to specify.

We have to select any option and provide the required input then click on the Next button.

How to work with Recovery Operation- Close Processes Screen?

If we choose a Close application process recovery operation in the Recovery Operation screen the Recovery Operation – Close Processes screen opens.

The screen will look like

Select Process Screen in UFT Recovery Scenario
Select Process Screen in UFT Recovery Scenario

The Running processes list displays all application processes that are currently running. The process to close list displays the application processes that will be closed when the trigger is activated.We can add application processes to the Processes to close list by typing them in the process list.

To Add a process from the Running Processes list, we need to double click a process in the Running Processes list or select the same then click Add button. Refer to the above section for more details.

How to work with Recovery Operation- Function Call Screen?

If we chose a Function call recovery operation in the Recovery Operation screen, the Recovery Operation – Function Call screen opens. The below section will talk about the UFT/QTP recovery scenario function call example.

The screen will look like

Recovery Operation- Function Call screen
Recovery Operation- Function Call screen

We need to select a recently specified library file in the Library file box. Alternatively, we can click the browse button to navigate to an existing library file.

UFT/QTP automatically associates the library file we select with our test or component. Therefore, we do not need to associate the library file with our test or component in the Resources tab of the Test Settings dialog box or Business Component Settings dialog box, respectively.

After we select a library file, we need to choose one of the following options:

  • Select function –We can choose an existing function from the library file we selected. Only functions that match the prototype syntax for the trigger type selected in the Select Trigger Event screen are displayed.

Following is the prototype for each trigger type:

Test run error trigger

OnRunStep
{
[In] Object as Obiect: The object of the current step.
[In] Method as String: The method of the current step.
[In] Arguments as Array: The actual method's arguments
[In] Result as Integer: The actual method
}

Pop – up window and Object state triggers

OnObject
{
[in] Object as Object: The detected object.
}

Application Crash Trigger

OnProcess
{
[in] Process Name as String: The detected process's Name.
[in] Processid as Integer: The detected process' ID.
}
  • Define New Function –We can create a new function by specifying a unique name for it and defining the function in the Function Name box according to the displayed function prototype. The new function is added to the library file we selected.

If more than one scenario uses a function with the same name from different library files, the recovery process may fail. In this case, information regarding the recovery failure is displayed during the run session.

Click on the Next button to reopen the recovery screen.

How to work on Post Recovery Test Run Options Screen?

When we clear the Add another recovery operation checkbox in the Recovery Operations screen and click Next, the Post – Recovery Test Run Options screen opens.

The post-recovery screen will look like:

Recovery Scenario Post Recovery Test Run Options
Recovery Scenario Post Recovery Test Run Options

Post-recovery test run options specify how to continue the run session after UFT/QTP has identified the event and performed all of the specified recovery operations.

UFT/QTP can perform one of the following run session options after it performs the recovery operations we defined:

  • Repeat current step and continue – the current step is the step that UFT/QTP was running when the recovery scenario was triggered. If we are using the On error activation option for recovery scenarios, the step that returns the error is often one or more steps later than the step that caused the trigger event to occur. Thus, in most cases, repeating the current step does not repeat the trigger event.
  • Proceed to next step – Skips the step that UFT/QTP was running when the recovery scenario was triggered. We need to keep in mind that skipping a step that performs operations on our application may cause subsequent steps to fail.
  • Proceed to next action Iteration – UFT/QTP Stops performing steps in the current action iteration and begins the next action iteration from the beginning (or the next action if no additional iterations of the current action are required).
  • Proceed to next test iteration- UFT/QTP stops performing steps in the current action and begins the next test iteration from the beginning (or stops running the test if no additional iterations are required).
  • Restart current test run – UFT/QTP stops performing steps and re-runs the test or component from the beginning.
  • Stop the test run – UFT/QTP stops running the test or component.

If we choose Restart Microsoft Windows as a recovery operation, we can choose from only the last two test run options listed above.

However, to proceed, select an option and click on the Next button.

How to Provide Name and Description for a Recovery Scenario?

After we specify a test run option in the Post – Recovery Test Run Options screen and click Next
the Name and Description screen open.

The screen looks like:

Name and Description Screen in Recovery Scenario
Name and Description Screen in the Recovery Scenario

In the Name and Description screen, we specify a name by which we can identify our recovery scenario. we can also add descriptive information regarding the scenario.

We need to enter a name and a textual description for our recovery scenario and click Next to continue to Completing the Recovery Scenario Wizard screen.

Final and Complete Recovery Scenario Wizard Screen

After we specify a recovery scenario name and description in the Name and Description screen and click Next, Completing the Recovery Scenario Wizard screen opens.

The Screen looks like

Completing the Recovery Scenario Wizard
Completing the Recovery Scenario Wizard

In the Completing the Recovery Scenario Wizard screen, we can review a summary of the scenario settings we defined. we can also specify whether to automatically associate the recovery scenario with the current test or component and/ or to add it to the default settings for all new tests.

We can select the Add scenario to current test checkbox to associate this recovery scenario with the current test or component. When we click Finish, UFT/QTP adds the recovery scenario to the Scenarios list in the Recovery tab of the Test Settings dialog box or Business Component Settings dialog box, respectively.

We can select the Add scenario to default test settings checkbox to make this recovery scenario a default scenario for all new tests. The next time we create a test, this scenario will be listed in the Scenarios list in the Recovery tab of the Test Settings dialog box.

Note

  • We can remove scenarios from the default scenarios list.
  • We define the default recovery scenarios for all new components in the component template.

We need to click the Finish button to complete the recovery scenario definition.

How to Save Recovery Scenario in a Recovery File?

After we create or modify a recovery scenario in a recovery file using the Recovery Scenario Wizard, we need to save the recovery file.  To save a new or modified recovery file we need to follow the below-written steps:

  • We need to click the Save button. If we added or modified scenarios in an existing recovery file, the recovery file and its scenarios are saved. If we are using a new recovery file, the Save Attachment dialog box opens. we can also click the arrow to the right of the Save button and select Save As to save the recovery file under a different name.
  • We need to choose the folder in which we want to save the file.
  • We need to type a name for the file in the File name box. The recovery file is saved in the specified location with the file extension (.qrs). It is the recovery scenario extension in uft.  Full form QuickTest Recovery Scenario.
  • If we have not yet saved the recovery file, and we click the Close button in the Recovery Scenario Manager dialog box, UFT/QTP prompts us to save the recovery file. Click Yes, and proceed with step 2 above. If we added or modified scenarios in an existing recovery file, and we click Yes to the message prompt, the recovery file scenarios are saved.

How to Manage Recovery Scenarios?

Once we have created recovery scenarios, we can use the Recovery Scenario Manager to manage them. This section talk about recovery scenario manager in UFT/QTP with example.

The recovery scenario manager window looks like

Recovery Scenario Manager controller view
Recovery Scenario Manager controller view

These icons indicate the status of the scenario: defined here

IconDescription
This indicates that the recovery scenario is triggered when a window pops up in an open application during the run session.
This indicates that the recovery scenario is triggered when the property values of an object in an application match specified values.
It indicates that the recovery scenario is triggered when a step in the test or component does not run successfully.
This indicates that the recovery scenario is triggered when an open application fails during the run session.

The Recovery Scenario Manager provides us the capabilities so that we to manage existing scenarios by:

  • Viewing Recovery Scenario Properties
  • Modifying Recovery Scenarios
  • Deleting Recovery Scenarios Scenario Files
  • Copying Recovery Scenarios between Recovery Scenario Files

How to view Recovery Scenario Properties?

we can view properties for any defined recovery scenario. To view recovery scenario properties, we need to perform the following steps:

  • In the Scenarios box, select the recovery scenario whose properties we want to view.
  • We need to click the Properties button. Alternatively, we can double – click a scenario in the Scenarios box. The Recovery Scenario Properties dialog box opens.

The dialog box looks like

Recovery Scenario Properties
Recovery Scenario Properties

Recovery Scenario Properties dialog box displays the following read-only information about the selected scenario.

  • General tab –UFT/QTP displays the name and description defined for the recovery scenario, plus the name and path of the recovery file in which the scenario is saved.
  • Trigger Event tab – UFT/QTP displays the settings for the trigger event defined for the recovery scenario.
  • Recovery operation tab– UFT/QTP displays the recovery operation (s) defined for the recovery scenario.
  • Post-Recovery Operation tab– UFT/QTP displays the post-recovery operation defined for the recovery scenario.

How to modify a Recovery Scenario in UFT/QTP?

we can modify the settings for an existing recovery scenario. To modify a recovery scenario we need to follow the following steps:

  • In the Scenarios box, we need to select the scenario that we want to modify.
  • We need to click the Edit button. The Recovery Scenario Wizard opens, with the settings we defined for the selected recovery scenario.
  • We need to navigate through the Recovery Scenario Wizard and modify the details as needed.

Modifications we make are not saved until we click Save in the Recovery Scenario Manager dialog box. If we have not yet saved our modifications, and we click the Close button in the Recovery Scenario Manager dialog box, UFT/QTP prompts us to save the recovery file.

  • We need to click Yes to save our changes.

How to delete Recovery Scenario from our test or component?

we can delete an existing recovery scenario if we no longer need it. When we delete a recovery scenario from the Recovery Scenario Manager, the corresponding Information is deleted from the recovery scenario file. If a deleted recovery scenario is associated with a test or component, UFT/QTP ignores it during the run session.

READ  Learn How to Work with XML with UFT in Fast and Effortless Manner

To delete a recovery scenario we need to follow the following steps:

  • In the Scenarios box, we need to select the scenario that we want to delete.
  • We need to click the Delete button. The recovery scenario is deleted from the Recovery Scenario Manager dialog box.

The scenario is not actually deleted until we click on the Save button in the Recovery Scenario Manager dialog box. If we have not yet saved the deletion, and we click the Close button in the Recovery Scenario Manager dialog box, UFT/QTP prompts us to save the recovery file. Click Yes to save the recovery scenario file and delete the scenarios.

How to copy Recovery Scenarios between Recovery Scenario Files?

In order to copy recovery scenarios between recovery scenario files, we need to perform the following steps:

  • In the Scenarios box, we need to select the recovery scenario that we want to copy.
  • We have to click the Copy button.Once we click on the Copy button, the scenario is copied to the Clipboard.
  • We have to click the Open button and select the recovery scenario file to which we we want to copy the scenario, or click the New button to create a new recovery scenario file in which, we want to copy the scenario.
  • We need to click the Paste button. The scenario is copied to the new recovery scenario file.

If a scenario with the same name already exists in the recovery scenario cenario file file. we can choose whether we want to replace it with the new scenario we have just copied.

Modifications we make are not saved until we click Save in the Recovery Scenario Manager dialog box. If we have not yet saved our modifications, and we click the Close button in the Recovery Scenario Manager dialog box, UFT/QTP prompts us to save the recovery file.

  • Click Yes to save our changes.

How to set up the Recovery Scenarios List for our Tests or Components?

After we have created recovery scenarios, we associate them with selected tests or components so that UFT/QTP will perform the appropriate scenario (s) during the run sessions if a trigger event occurs. we can prioritize the scenarios and set the order in which UFT/QTP applies the scenarios during the run session.

We can also choose to disable specific scenarios, or all scenarios, that are associated with a test or component. we can also define which recovery scenarios will be used as the default scenarios for all new tests. We can define the default recovery scenarios for all new components in the component template.

How to add Recovery Scenarios to our Test or Component?

After we have created recovery scenarios, we can associate one or more more scenarios with will a test or component in order to instruct UFT/QTP to perform the recovery scenario(s) during the run session if a trigger event occurs.

The Recovery tab of the Test Settings dialog box or Business Component Settings dialog box lists all the recovery scenarios associated with the current test or component.

When a trigger event occurs, UFT/QTP checks for applicable recovery scenarios in the order in which they are displayed in the Recovery tab.

  • Navigation: File Settings | Select Recovery Tab
Add Recovery to test or component
Add Recovery to test or component
  • We need to click on Add (+)button. The Add Recovery Scenario box opens. The box will look like
Add Recovery Scenario To Test or Component
Add Recovery Scenario To Test or Component
  • In the Recovery file box, select the recovery file containing the recovery scenario (s) we want to associate with the test or component. Alternatively, click the browse button to navigate to the recovery file we want to select. The Scenarios box displays the names of the scenarios saved in the selected file.
  • In the Scenarios box,We need to select the scenario (s) that we want to associate with the test or component and click Add Scenario. The Add Recovery Scenario dialog box closes and the selected scenarios are added to the Scenarios list in the Recovery tab.

We can edit a recovery scenario file path by clicking the path once to highlight it, and then clicking it again to enter edit mode. For example, we may want to modify an absolute file path to be a relative file path. If we modify a recovery scenario file path, we must ensure that the recovery scenario is defined in the new path location before running our test or component.

How to view Recovery Scenario Properties that is attached to a Test or Component?

We can view properties for any recovery scenario associated with our test or component. We modify recovery scenario settings from the Recovery Scenario Manager dialog box.

In order to view recovery scenario properties we need to follow the below steps:

  • In the Scenarios box, we need to select the recovery scenario whose properties we want to view.
  • We need to click the Properties button. Alternatively, we can double – click a scenario in the Scenarios box.
  • The Recovery Scenario Properties dialog box opens, displaying read – only information regarding the settings for the selected scenario.

How to Set up Recovery Scenario Priority?

we can specify the order in which UFT/QTP performs associated scenarios during a run session. When a trigger event occurs, UFT/QTP checks for applicable recovery scenarios in the order in which they are displayed in the Recovery tab of the Test Settings dialog box or Business Component Settings dialog box.

To set recovery scenario priorities, we need to perform the following steps:

  • In the Scenarios box, we need to select the scenario whose priority we want to change.
  • We have to click the Up or Down button. The selected scenario ‘ s priority changes according to our selection.
  • We can repeat steps 1 – 2 for each scenario whose priority we want to change.

How to remove Recovery Scenarios from Test or Component?

we can remove the association between a specific scenario and a test or component using the Recovery tab of the Test Settings dialog box or Business Component Settings dialog box. After we remove a scenario from a test or component, the scenario itself still exists, but UFT/QTP will no longer perform the scenario during a run session.

To perform the removing operation, we need to perform the following steps:

  • In the Scenarios box, we need to select the scenario we want to remove.
  • We need to click the Remove button. Once we click, the selected scenario is no longer associated with the test or component.

How to enable or disable Recovery Scenarios from Test or Component?

we can enable or disable specific scenarios and determine when UFT/QTP activates the recovery scenario mechanism in the Recovery tab of the Test Settings dialog box or Business Component Settings dialog box. When we disable a specific scenario, it remains associated with the test or component but is not performed by UFT/QTP during the run session. we can enable the scenario at a later time or whenever we want.

To enable/ disable specific recovery scenarios, we have to perform the following  steps:

  • We need to select the checkbox to the left of one or more individual scenarios to enable them.
  • We need to clear the checkbox to the left of one or more individual scenarios to disable them.

How to define when the Recovery mechanism is activated?

We have to select one of the following options in the Activate recovery scenarios box to define when to activate the Recovery Scenario:

  • On every step – – The recovery mechanism is activated after every step. Choosing On every step may result in slower performance during the run session.
  • On error – The recovery mechanism is activated only after steps that return an error return value. The step that returns an error is often not  the same as the step that causes the exception event to occur.
  • Never – The recovery mechanism is disabled.

Let us consider an example, A step that selects a checkbox may cause a pop – up dialog box to open. Altho Although the pop – up dialog box is defined as a trigger event, UFT/QTP moves to the next step because it successfully performed the checkbox selection step.

The next several steps could potentially perform checkpoints, functions or other conditional or looping statements that do not require performing operations on our application.

It may only be several statements later that a step instructs UFT/QTP to perform an operation on the application that it cannot perform due to the popup dialog box. In this case, it is this Nth step that returns an error and triggers the recovery mechanism to close the dialog box. After the recovery operation is completed, the current step is this Nth step and not the step that caused the trigger event.

How to set up Default Recovery Scenario Settings for All-New Tests?

we can click the Set as Default button in the Recovery tab of the Test Settings dialog box to set the current list of recovery scenarios to be the default scenarios for all new tests. Any future changes we make to the current recovery scenario list only affect the current test and do not change the default list that we defined. we define the default recovery scenarios for all components in the component template.

how to add recovery scenario in UFT/QTP at run time? or How to control the Recovery mechanism programmatically?

We can also enable or disable specific scenarios or all scenarios associated with a test or component programmatically during the run session.

We can use the Recovery object to control the recovery mechanism programmatically during the run session. For example, we can enable or disable the entire recovery mechanism-specific recovery scenarios for certain parts of a run session, retrieve status information about specific recovery scenarios, and explicitly activate the recovery mechanism at a certain point in the run session.

In general, UFT/QTP checks for recovery triggers when an error is returned during the run session. We can use the Recovery Object’s Activate()  method to force UFT/QTP to check for triggers after a specific test step in the run session.

For example, let’s assume that we know that an object property checkpoint will fail if certain processes are open when the checkpoint is performed. We want to be sure that the pass or fail of the checkpoint is not affected by these open processes which may indicate a different problem with our application.

A failed checkpoint does not result in a run error. So by default, the recovery mechanism will not be activated by the object state. We can define a recovery scenario that looks for and does specify open processes when an object’s properties have a certain state.

This state shows the object’s property values as they will be if the problematic process is opened. We can instruct UFT/QTP to activate the recovery mechanism if the checkpoint fails so that UFT/QTP will check for and close any problematic open processes and then try to perform the checkpoint again. This ensures that when the checkpoint is performed the second time, it is not affected by the open processes.

Popular control mechanism UFT/QTP borrowed from VBScript are as follows:

  • On Error Go to 0.
  • On Error Resume Next

With these, we can some what control the execution but they can not be used as an alternative to recovery scenario.

This AOM post has more details about how to control Recovery files programatically.

Conclusion

We have learned in detail on Recovery Scenario, how to create, configure and use them manually and automatically.  This post will also help you to clear recovery scenarios in UFT/QTP interview questions.

If you enjoyed this post, please share it on social media ?What am I missing here? Let me know in the comments and I’ll add it in!”

Ref: Microfocus Recovery Scenario

 

Share and Enjoy !

Leave a Comment

Your email address will not be published. Required fields are marked *