Tuesday, July 31, 2012

Recovery Vs On error Resume Next

*********************************************************************************
What is Recovery and  On error Resume Next?
*********************************************************************************
        Recovery scenario mechanism  and On error Resume Next both are used to avoid the effect
of unexpected errors caused by the application as well as script

*********************************************************************************
Why Recovery and On error Resume Next?
*********************************************************************************
         As automation test engineer we need to develops the scripts such away that scripts shouldn' t effect  even if any unexpectd error occurs

*********************************************************************************
Genaerally while executing scripts we may get two types of unexpected errors

1)Error From application
2)Error From Script

*********************************************************************************
How to handle the Error in the application?
*********************************************************************************
                      To handle the Unexpected errors in application we will use QTP recovery scenarios mechanism or by VB script if else condition

*********************************************************************************
How to handle the Error in the Script?
*********************************************************************************
            To handle the Unexpected errors in script we will use VB script On error resume next

*********************************************************************************


On error Resume Next

**********************************************************************************
Why On Error Resume Next:
**********************************************************************************
To avoid the unexpected errors caused by the script

**********************************************************************************
What "On Error Resume Next" will do?
***********************************************************************************
These Statment will supress the error produced by the script and resumes the next step

***********************************************************************************
On Error Goto 0
***********************************************************************************
These will be helpful to disabled the Activated On error resume next statement

***********************************************************************************
Err Object :
***********************************************************************************
In VB Script every single statement will produce the Error number,if it is Zero stament is correct else statment is false

***********************************************************************************
To get the error number :
***********************************************************************************
msbox Err .number

***********************************************************************************
To get the error Description:
***********************************************************************************
msgbbox Err.Description

***********************************************************************************
To clear the error:
***********************************************************************************
Err.Clear

Note: When We get the error number through Err object, we should explicitly clear the error number,otherwise script will carries only one number
***********************************************************************************
To raise the error:
***********************************************************************************
Err.Raise

***********************************************************************************
Note : On Error Resume Next will handle the only Script error not application errors
***********************************************************************************