Tuesday, 26 November 2013

Error Handling in QTP

There are 2 ways in which we can handle errors in QTP.

  1. Err object.
  2. Recovery Scenarios.
Sample code to handle the error is given below

If err.number <> 0 Then
print err.description
else
print "there  was no error in above statement"
end if 


Whenever any error occurs in the script, We get the message window with detailed description of the error.

But when we are executing the scripts, we do not want this message box to appear to come as this will halt the execution of the script.

To prevent message box from appearing, we use below statement above the block of code.

On error resume next
----------
----------
more statements

With On error resume next in place, QTP script runs even though error exists in the code. We can capture those errors using Err object as stated earlier.

When you are debugging the scripts, you should not use On error resume next statement as it will suppress the errors and you will not be able to figure out the issue in your script.

You may also like below topics on error handling in QTP.

  1. On error resume next in QTP
  2. Err.Number in QTP

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

No comments:

Post a Comment

Please Leave your reply. We value your feedback and inputs

Best QTP Books

Everything About QTP

Hello Friends,
You can find QTP study material, Multiple choice questions (mcq), QTP question bank, QTP question papers, QTP notes, QTP questionnaire, scenario based QTP interview questions, QTP tutorial and QTP training on this site.

If you are a fresher or experienced QTP professional with (1/2/3/4) years of experience, this blog is just for you.