Facebook

For any corporate training requirements Please mail To sudhakar@qtpsudhakar.com
New Schedule in MindQ Systems, Madhapur By SUDHAKAR
Course Name Date Time Duration Type Branch
Selenium+Appium 16th October 2017 7.30 AM - 9.00 AM IST 45 Days ClassRoom + Online Mind Q Madhapur
Selenium+Appium 30th October 2017 9.30 AM - 11.00 AM IST 45 Days ClassRoom + Online Mind Q Madhapur

A book "Cracking the QTP interview" authored by Sudhakar.Read More. Buy From FlipKart

Friday, June 14, 2013

Error Handling and Recovery Scenarios in QTP - Part-1

Error Handling and Recovery Scenarios in QTP - Part-1

Introduction

Just think… What type of errors/blockers we get when testing an application? (in Manual Testing)

    1. Defects in Application
    2. System Environment Issues like Browser is getting closed automatically
    3. Application Down for some time
    4. Unexpected Popup Windows which are not documented in Testcase

These are some sample issues in manual testing. What will a manual tester do in above situations?

Simple. He will use some sense. If there are defects, He will stop executing that testcase and reports it. If browser got closed He will reopen the browser and continues the execution. If application is down, He will stop executing the testcases. He will take the required action for Popup windows. He can do because he can change his mind dynamically.

When it comes to Automation, the script will play the role of manual tester. But the Automation Tester should provide enough intelligence to the script to handle above errors like the way how those handled manually.

To provide that strength to the script, Automation Tester will use VB Script Err Object and Recovery Scenarios.

So what type of errors we get when executing a script?

    1. Popup Windows (Security Popups)
    2. Object State Change (Application Down/ Display of Validation Errors)
    3. Script Errors (Due to poor coding)
    4. Sudden Death of Application (Computer Problem/OS Problem)

How Recovery Scenarios will provide strength to Script?

Recovery Scenarios are useful to continue the execution when it is interrupted by any unexpected event/error. When error occurs, the error information will be collected by QTP Recovery Mechanism and a predefine recovery scenario will be executed to overcome the error and to continue the execution. The predefined recovery scenarios will be developed by the Automation Tester.

A Recovery Scenario consists of 3 sections

    1. Type of Error
    2. What is the operation you want to perform (To Overcome the Error)
    3. What do you want to do after performing the operation (To Continue the execution)

The Automation Tester will think of every possible error that might occur in execution time and prepares recovery scenarios for them as per the above model and associate them in Test Settings of QTP Test.

clip_image001

Figure 1: Associated Recovery Scenarios

When execution got interrupted due to an error, QTP applies the specified Recovery Scenarios as per the prioritization. The Recovery Operation will be executed when the error details specified in Recovery Scenario got matched with the error that is caused interruption to the execution.

How to Define a Recovery Scenario?

Technically the above 3 sections are called as below

    1. Trigger Event
    2. Recovery Operation
    3. Post Recovery Operation

Trigger Event: The type of event that is causing interruption to the execution.

Type of Trigger Events:

    1. Popup Window
    2. Object State
    3. Test Run Error
    4. Application Crash

clip_image002

Figure 2: Trigger Events

The below information is required for each trigger event. This information will be used to match the errors that are occurred in execution time.

Trigger Event

Required Details to Specify

Popup Window

Window Details

Object State

Object Details (specify the properties of the object with values)

Test Run Error

Type of Error

Application Crash

Application Process Name

Recovery Operation: The operations that are required to clear the errors/blockers that are interrupted the execution. The Recovery Operation will be executed only when Trigger Details and Error details are matched.

The below recovery operations available in QTP

    1. Keyboard or Mouse Operation
    2. Close Application Process
    3. Function Call
    4. Restart Microsoft Windows

clip_image003

Figure 3: Recovery Operations

Keyboard or Mouse Operation

A Keyboard stroke/ Mouse click will be performed. It will be used when there is only one step operation is required. Ex: Click a button

Close Application Process

The specified process will be closed. It will be used when any other application is interrupting execution. Ex: An antivirus system blocking execution.

Function Call

A library function will be called. It will be used when there are multiple steps need to be executed. Ex: When providing functional alternative, When you want to analyze the error and perform operation

Restart Microsoft Windows

QTP Restarts the Operating System. This will be used when the execution blocked because of a pending restart.

Post Recovery Operations: Recovery Operation used to clear the errors/blockers of execution.
But Post Recovery Operations provide a facility on how you want to continue the execution after performing the Recovery Operation.

The below are Post Recovery Operations

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

clip_image004

Figure 4: Post Recovery Operations

Why Post Recovery Operations are required?

What will happen when an Application got crashed? We will reopen the application. But how the execution will be continued? If 50 steps are executed for a script, How recovery operation will execute those 50 steps and continues the execution. No way. This type of cases we just use Restart Current Test Run as Post Recovery Operation.

So Post Recovery Operations are useful to continue the execution based on the performed Recovery Operation. It’s also useful to quit the execution in proper way.

Repeat Current Step and Continue

By default Recovery Scenarios will be executed when execution got interrupted due to an error. There is a facility to execute recovery scenarios for each step. I.e. whether you get error or not Recovery Scenarios will be executed. Executing them for each step will make low performance for the script and hence by default the Recovery Scenarios will be activated on error (Observe Figure1).

QTP understands that there is an error only when a step got failed. If that is important step and recovery operation is covering it then we choose Repeat Current Step and Continue option.

Ex: Login button got disabled QTP tries to click on it and failed. Recovery operation did something to enable Login button. QTP already executed clicking on Login button and it will try to execute next step which will become fail. In this case “Repeat Current Step and Continue” will make QTP to re-execute the clicking on login button step.

Proceed to Next Step

If the failed is not important or if Recovery Operation completely clears the way for execution then this option will be useful.

Proceed to next Action or Component Iteration

Exit from current Action iteration and starts executing next Iteration. This will be used when a Test is using Actions concept and you want to skip the only that Action iteration execution. This option is useful to execute the same Action with next set of data that is available in datatable. Component is the concept of BPT (Business Process Test).

Proceed to next Test Iteration

Exit from current Test iteration and starts executing next Iteration. This option is useful to execute the same Test with next set of data that is available in datatable. The above two are based Iterations concept. Please go thru below link to understand Test/Action Iterations. http://www.qtpsudhakar.com/2009/07/test-action-iterations.html.

Restart current test run

Restart the current Test Run. This option is used when there is the functional flow got disturbed and not able to continue the execution.

Stop the Test Run

Stops running that Test. This will be used when application is down or an open defect still there and no need to continue the execution of that test.

<Read Error Handling and Recovery Scenarios in QTP - Part-2>

1 comment :