Recovery Scenario
You can instruct Quick Test to recover from unexpected events and errors that occur in your testing environment during a test run. Unexpected events, errors, and application crashes during a test run can disrupt your test and distort test results. This is a problem particularly when running tests unattended—the test is suspended until you perform the action needed to recover.
The Recovery Scenario Manager provides a wizard that guides you through the process of defining a recovery scenario—a definition of an unexpected event and the operation(s) necessary to recover the test run. For example, you can instruct Quick Test to detect a Printer out of paper message and recover the test run by clicking the OK button to close the message and continue the test.
A recovery scenario consists of the following:
Ø Trigger Event—The event that interrupts your test run. For example, a window that may pop up on screen, or a Quick Test test run error.
Ø Recovery Operation(s)—The operation(s) that need to be performed in order to continue running the test. For example, clicking an OK button in a pop-up window, or restarting Microsoft Windows.
Ø Post-Recovery Test Run Option—The instructions on how Quick Test should proceed once the recovery operations have been performed, and from which point in the test Quick Test should continue, if at all. For example, you may want to restart a test from the beginning, or skip a test step entirely and continue with the next step in the test.
Recovery scenarios are saved in recovery scenario files. A recovery scenario file is a logical collection of recovery scenarios, grouped according to your own specific requirements.
To instruct Quick Test to perform a recovery scenario during a test run, you must first associate it with that test. A test can have any number of recovery scenarios associated with it. You can prioritize the scenarios associated with your test to ensure that trigger events are recognized and handled in the required order.
When you run a test for which you have defined recovery scenarios and an error occurs, Quick Test looks for the defined trigger event(s) that caused the error. If a trigger event has occurred, Quick Test performs the corresponding recovery and post-recovery operations.
You can also control and activate your recovery scenarios during the test run by inserting Recovery statements into your test.
Note: If you choose On error in the Activate recovery scenarios box in the Recovery tab of the Test Settings dialog box, the recovery mechanism does not handle triggers that occur in the last step of a test. If you chose this option and need to recover from an unexpected event or error that may occur in the last step, you of a test can do this by adding an extra step to the end of your test.
14.1 Exceptional Handling using Recovery Scenarios
The Recovery Scenario Manager dialog box enables you to create recovery scenarios and save them in recovery files. You create recovery scenarios using the Recovery Scenario Wizard, which leads you through the process of defining each of the stages of the recovery scenario. You then save the recovery scenarios in a recovery file, and associate them with a specific test or tests.
Creating a Recovery File
You save your recovery scenarios in a recovery file. A recovery file is a convenient way to organize and store multiple recovery scenarios together. You can create a new recovery file or edit an existing one.
For more information on creating a Recovery File refer to Creating a Recovery File
Saving the Recovery Scenario in a Recovery File
After you create or modify a recovery scenario in a recovery file using the Recovery Scenario Wizard, you need to save the recovery file.
To save a new or modified recovery file:
1. Click the Save button . If you added or modified scenarios in an existing recovery file, the recovery file and its scenarios are saved. If you are using a new recovery file, the Save Attachment dialog box opens.
Tip: You 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.
2. Choose the folder in which you want to save the file.
3. 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.
Tip: If you have not yet saved the recovery file, and you click the Close button in the Recovery Scenario Manager dialog box, Quick Test prompts you to save the recovery file. Click Yes, and proceed with step 2 above. If you added or modified scenarios in an existing recovery file, and you click Yes to the message prompt, the recovery file and its scenarios are saved.
Managing Recovery Scenarios
Once you have created recovery scenarios, you can use the Recovery Scenario Manager to manage them.
The Recovery Scenario Manager contains the following recovery scenario icons:
Icon
Description
Indicates that the recovery scenario is triggered when a window pops up in an open application during the test run.
Indicates that the recovery scenario is triggered when the property values of an object in an application match specified values.
Indicates that the recovery scenario is triggered when a step in the test does not run successfully.
Indicates that the recovery scenario is triggered when an open application fails during the test run.
The Recovery Scenario Manager enables you to manage existing scenarios by:
Ø Viewing Recovery Scenario Properties
Ø Modifying Recovery Scenarios
Ø Deleting Recovery Scenarios
Ø Copying Recovery Scenarios between Recovery Scenario Files
Viewing Recovery Scenario Properties
You can view properties for any defined recovery scenario.
To view recovery scenario properties:
1 In the Scenarios box, select the recovery scenario whose properties you want to view.
2 Click the Properties button . Alternatively, you can double-click a scenario in the
Scenarios box. The Recovery Scenario Properties dialog box opens.
The Recovery Scenario Properties dialog box displays the following read-only information about the selected scenario:
Ø General tab—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—Displays the settings for the trigger event defined for the recovery scenario.
Ø Recovery operation tab—Displays the recovery operation(s) defined for the recovery scenario.
Ø Post-Recovery Operation tab—Displays the post-recovery operation defined for the recovery scenario.
Modifying Recovery Scenarios
You can modify the settings for an existing recovery scenario.
To modify a recovery scenario:
1 In the Scenarios box, select the scenario that you want to modify.
2 Click the Edit button . The Recovery Scenario Wizard opens, with the settings you defined for the selected recovery scenario.
3 Navigate through the Recovery Scenario Wizard and modify the details as needed.
Deleting Recovery Scenarios
You can delete an existing recovery scenario if you no longer need it. When you delete a recovery scenario from the Recovery Scenario Manager, the corresponding information is deleted from the recovery scenario file.
Note: If a deleted recovery scenario is associated with a test, Quick Test ignores it during the test run.
To delete a recovery scenario:
1 In the Scenarios box, select the scenario that you want to delete.
2 Click the Delete button . The recovery scenario is deleted.
Copying Recovery Scenarios between Recovery Scenario Files
You can copy recovery scenarios from one recovery scenario file to another.
To copy a recovery scenario from one recovery scenario file to another:
1 In the Scenarios box, select the recovery scenario that you want to copy.
2 Click the Copy button . The scenario is copied to the Clipboard.
3 Click the Open button and select the recovery scenario file to which you want to copy the scenario, or click the New button to create a new recovery scenario file in which to copy the scenario.
4 Click the Paste button . The scenario is copied to the new recovery scenario file.
Note: If a scenario with the same name already exists in the recovery scenario file, you can choose whether you want to replace it with the new scenario you have just copied.
Setting the Recovery Scenarios List for Your Tests
After you have created recovery scenarios, you associate them with selected tests so that Quick Test will perform the appropriate scenario(s) during the test runs if a trigger event occurs. You can prioritize the scenarios and set the order in which Quick Test applies the
scenarios during the test run. You can also choose to disable specific scenarios, or all scenarios, that are associated with a test. You can also define which recovery scenarios will be used as the default scenarios for all new tests.
Adding Recovery Scenarios to Your Test
After you have created recovery scenarios, you can associate one or more scenarios with a test in order to instruct Quick Test to perform the recovery scenario(s) during the test run if a trigger event occurs. The Recovery tab of the Test Settings dialog box lists all the recovery scenarios associated with the current test.
Tip: When a trigger event occurs, Quick Test checks for applicable recovery scenarios in the order in which they are displayed in the Recovery tab. You can change this order as described in “Setting Recovery Scenario Priorities”
For more information on “adding a recovery scenario to a test” refer to Adding Recovery Scenario to a Test
Viewing Recovery Scenario Properties
You can view properties for any recovery scenario associated with your test.
To view recovery scenario properties:
1 In the Scenarios box, select the recovery scenario whose properties you want to view.
2 Click the Properties button . Alternatively, you 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.
Setting Recovery Scenario Priorities
You can specify the order in which Quick Test performs associated scenarios during a test run. When a trigger event occurs, Quick Test checks for applicable recovery scenarios in the order in which they are displayed in the Recovery tab of the Test Settings dialog box.
To set recovery scenario priorities:
1 In the Scenarios box, select the scenario whose priority you want to change.
2 Click the Up or Down button . The selected scenario’s priority changes according to your selection.
3 Repeat steps 1-2 for each scenario whose priority you want to change.
Removing Recovery Scenarios from Your Test
You can remove the association between a specific scenario and a test using the Recovery tab of the Test Settings dialog box. After you remove a scenario from a test, the scenario itself still exists, but Quick Test will no longer perform the scenario during a test run.
To remove a recovery scenario from your test:
1 In the Scenarios box, select the scenario you want to remove.
2 Click the Remove button . The selected scenario is no longer associated with the test.
Enabling and Disabling Recovery Scenarios
You can enable or disable specific scenarios and determine when Quick Test activates the recovery scenario mechanism in the Recovery tab of the Test Settings dialog box. When you disable a specific scenario, it remains associated with the test, but is not performed by Quick Test during the test run. You can enable the scenario at a later time.
To enable/disable specific recovery scenarios:
Ø Select the check box to the left of one or more individual scenarios to enable them.
Ø Clear the check box to the left of one or more individual scenarios to disable them.
To define when the recovery mechanism is activated:
Select one of the following options in the Activate recovery scenarios box:
Ø Always—The recovery mechanism is activated after every step.
Ø On error—The recovery mechanism is activated only after steps that return an error return value.
Note that the step that returns an error is often not the same as the step that causes the exception event to occur.
For example, a step that selects a check box may cause a pop-up dialog box to open. Although the pop-up dialog box is defined as a trigger event, Quick Test moves to the next step because it successfully performed the check box selection step. The next several steps could potentially perform checkpoints, functions or other conditional or looping statements that do not require performing operations on your application. It may only be ten statements later that a step instructs Quick Test to perform an operation on the application that it cannot perform due to the pop-up dialog box. In this case, it is this tenth 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 tenth step, and not the step that caused the trigger event.
Ø Never—The recovery mechanism is disabled.
Setting Default Recovery Scenario Settings for All New Tests
You 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 you make to the current recovery scenario list only affect the current test, and do not change the default list that you defined.
14.2 Sample for Recovery Scenario:
For adding a recovery Scenario:
Let us take an example of a popup window exception,
In Flight Application, when we give wrong password in the login dialog box then we get the following popup window:
In order to handle this, take a new recovery scenario, in the “Select Trigger Event” screen of Recovery Scenario Wizard, select “pop-up window” Radio button as shown below,
In the next screen, we can specify Pop-up window condition, by spying the popup window, then details of the pop-up window appears as follows:
then in the next step, In the recovery operation screen select “keyboard or mouse operation” radio button, then in the next step select “Press ENTER Key” radio button,
In the next screen select “Add another recovery operation” check box as given below:
then in the next step, In the recovery operation screen select “function call” radio button
Specify the path and name of the library file which has the appropriate function for entering the password and clicking “ok” button of “Login” dialog box.
In the “Post-Recovery Test Run Options” screen select “Repeat current step and Continue” radio button, give a name to the recovery scenario, thus the recovery will be created.
Adding a Recovery scenario into the Test:
We can add the Recovery Scenario to our test in two ways.
We can add the Recovery Scenario to our test while we create a new Recovery Scenario by checking the “add Scenario to current test” check box in “Completing the Recovery Scenario Wizard” screen of Recovery Scenario Wizard.
The other way to add Recovery Scenario to our test is by adding the required scenario file in the recovery tab of Test Settings Dialog box.
15. Optional Steps
15.1 Description:
When running a test, if a step does not succeed in opening a dialog box, QuickTest does not necessarily abort the test run. It bypasses any step designated "optional" and continues running the test. By default, QuickTest automatically marks as optional steps that open certain dialog boxes. You can manually designate additional steps as optional.
If a dialog box may or may not appear at a particular instanse then that dialog box actions performed can be set as optional, so that it proceeds to the next step, if the screen or dialog box doesn’t appear or will continue the normal flow.
Default Optional Steps:
There are some default objects, which QTP recognizes as optional, for those objects QTP by default sets as optional, those objects are as follows:
Dialog boxes with title bar as
Auto Complete
File Download
Internet Explorer
Netscape
Enter Network Password
Error
Security Alert
Security Information
Security Warning
Username and Password Required
Setting Optional Steps:
There are two ways of setting Optional steps:
1. We can directly Right-click a step in the Keyword View and choose Optional Step. The Optional Step icon will be added next to the selected step.
2. You can also add an optional step from the Expert View by adding OptionalStep to the beginning of the VBScript statement.
Example:
OptionalStep.Browser("browser_name").Page("page_n ame").Link("link_name")
16. Reporting
The process of reporting is to customize the test results, and add the appropriate comments and reports to the test results to increase the readability of it. Reporting can be done in various formats.
Test Results Window
After a test run, we view the results in the Test Results window. By default, the Test Results window opens when a test run is completed.
Note: You can open the Test Results window as a standalone application from the Start menu. To open the Test Results window, choose Start > Programs > QuickTest Professional > Test Results Viewer.
The Test Results window contains the following key elements:
Menu bar—Displays menus of available commands.
Test results toolbar—Contains buttons for viewing test results (choose View > Test Results Toolbar to display the toolbar).
Test results tree—Contains a graphic representation of the test results in the test results tree.
Test results details—Contains details of the selected step.
Active Screen—Shows the active screen of the particular window or step in the results.
16.1 Different Options for Reporting
There are 3 options for screen capture the screens to the results:
· Always – adds screen shots to the results for every step.
· On Errors – adds screen shots only on occurrence of error
· On Errors and Warnings – adds on both errors and warnings.
· Never
Note: If “Always” option is selected then the result file will occupy lots of memory, thus selection of “Always” option should be done only if the client wants to view all the screen shots for reference during review.
16.2 Functions used for Reporting
1. ReportEvent Method
Reports an event to the Test Reports.
Syntax: Reporter.ReportEvent EventStatus, ReportStepName, Details [, in]
Argument
Type
Description
EventStatus
Number or pre-defined constant
Status of the report step:
0 or micPass: Causes the status of this step to be passed and sends the specified message to the report.
1 or micFail: Causes the status of this step to be failed and sends the specified message to the report. When this step runs, the test fails.
2 or micDone: Sends a message to the report without affecting the pass/fail status of the test.
3 or micWarning: Sends a warning message to the report, but does not cause the test to stop running, and does not affect the pass/fail status of the test.
4 or micInfo: Applies an information status (and icon) to the step. This status does not affect the pass/fail status of the test.
ReportStepName
String
Name of the intended step in the report (object name).
Details
String
Description of the report event. The string will be displayed in the step details frame in the test report .
in
N/A
Not in use.
Example
The following example uses the Report Event method to report that the checkpoint on this window has passed.
Reporter.ReportEvent 0,"Fax Order No. 12","The check point for this window has passed "
2. Filter Property
Retrieves or sets the current mode for displaying events in the Test Results. You can use this method to completely disable or enable reporting of steps following the statement, or you can indicate that you only want subsequent failed or failed and warning steps to be included in the report.
Syntax:
To retrieve the mode setting:
CurrentMode = Reporter.Filter
To set the mode:
Reporter.Filter = NewMode
The mode can be one of the following values:
Mode
Description
0 or rfEnableAll
Default. All reported events are displayed in the Test Results.
1 or rfEnableErrorsAndWarnings
Only event with a warning or fail status are displayed in the Test Results.
2 or rfEnableErrorsOnly
Only events with a fail status are displayed in the Test Results.
3 or rfDisableAll
No events are displayed in the Test Results.
Example
The following example uses the Filter method to report the following events in the Test Results: 1, 2, 5, and 6.
Reporter.ReportEvent micGeneral, "1", ""
Reporter.ReportEvent micGeneral, "2", ""
Reporter.Filter = rfDisableAll
Reporter.ReportEvent micGeneral, "3", ""
Reporter.ReportEvent micGeneral, "4", ""
Reporter.Filter = rfEnableAll
Reporter.ReportEvent micGeneral, "5", ""
Reporter.ReportEvent micGeneral, "6", "
3. ReportPath Property
Retrieves the folder path in which the current test's Test Results are stored.
Syntax
Path = Reporter.ReportPath
Argument
Type
Description
Path
String
The folder path in which the current test's Test Results are stored.
Example
The following example uses the ReportPath method to retrieve the folder in which the test's Test Results are stored and displays the folder in a message box.
dim Path
Path = Reporter.ReportPath
MsgBox (Path)
16.3 Reporting Formats
The results of the QTP runs are stored in the Results folder, which must be specified before starting the test run. The results are stored in 2 types of formats:
· QTP format – this is the format in which the results are displayed in the test window, opens with QTP
· XML format – the results are also stored in XML file, in which all the objects are stored in a hierarchy in .xml format. This is useful in transfer of the results information across platforms, since it is based on simple Unicode format.
Fig: results in XML format
Make the Quality Software
Tuesday, March 18, 2008
QTP Testing Process:-
Preparing to Record
Recording
Enhancing a Test
Debugging
Running the Test and Analyzing the Results
Reporting Defects
Labels: Testing Techniqes
