Software Testing Learning Hub

Error Handling in QuickTest Professional (QTP)

error handlingQuickTest and VBScript give the developer some tools for error handling and Exceptions. Every Tool or method references on the 5 topics of Error handling. Fault, Error, Detector, Failure and Exception. We Will start with the easiest topic, handling user and/or developer faults.

 

 

Error Handling Guidelines

Within every Action/Reusable Action/Function/procedure QA has to consider the possible exceptions and way to handlie them. Especially at begining of the script, it is important to handle all exceptions.

  • We want to relieve the developer from writing similar error handling code for every method.
  • We want to minimize the set of disastrous states by foreseeing these situations and thus converting them to expected situations.
  • Error handling at individual level should be possible whenever required.
  • Error handling should be consistent to keep it maintainable. It is important to provide some error handling for unexpected exceptions.
  • Changes to application code or extensions should not result in change requirements for a large number of error handlers

usually we will end the script, with a detailed message to the user, even an additional bitmap capture.
Finding errors in your scripts. Instead, use error-handling techniques to allow your program to continue executing even though a potentially fatal error has occurred. Normally, all runtime errors that are generated by the VBScript engine are fatal, since execution of the current script is halted when the error occurs. Error handling allows you to inform the user of the problem and either halt execution of the program or continue with same execution by ignoring an error.Below are some ways to handle the error occurs in AUT.

Data Validation
When function receives parameters use a data validation procedure using VarType, IsNumeric, IsNull, IsDate, IsEmpty VBScript functions. When a function receives a wrong parameter type, you will get sometimes an error description not so clear and accurate.

Error Preventing
A good method for using error handling is to try to prevent them. When an error occurred, Report it in detail. When working with GUI objects, use the Window.Exist property. Every If…Then..End If statement has the Else part, the same for Select Case. Use Case Else.

QuickTest Synchronization
QTP is designed in such a way that the default wait time to execute a action is 20 seconds.
on the application when we perform an action (exmple:  related to storing the data that we give in the database, in real time it takes  time to store. if it is more than 20 sec).when we RECORD  ACTIONS on the application, containing this particular ACTION using QTP and RUN,  as the application takes more time than 20 seconds to complete this action, QTP will show error message stating the object is disabled.and this is because of the default settings in QTP so even though the application is working fine, QTP shows error message because of internal default settings.
in This scenario we can use ,
>synchronization point for the Tool to wait till the ACTION is enabled so that QTP can successfully execute. or
>we can use wait statement or
>we can increase the QTP default time settings itself
Three methods are available in QTP for Synchronization

WaitProperty – method is used to instruct QTP to wait the execution process until it matches with the object property value based on the specified time.
E.g. Browser(“QEWorks”).WaitProperty “name”,”Welcome: QEWorks”, 5000

name –  property name
Welcome: Welcome: QEWorks
5000 – number of milli seconds to wait

Wait – method is used to instruct the QTP to wait the execution process based on
the specified time only but not on any condition
E.g. Wait 5 (or) Wait(5) ‘5 Seconds

Exist – method is used to instruct QTP to wait the execution process based on the
specified time and returns Boolean value as per the object existence
E.g. var_Exist = Browser(“Welcome: QEWorks”).Exist(5) ‘5 seconds

For successful execution of test scripts effective error handling is required.