How can I implement error handling in QTP

Showing Answers 1 - 5 of 5 Answers

You can use If-Else statement to implement error handling or Recovery scenario Manager. Like you have entered invalid password, then you will get the error message "Password is Invalid". If message="Password is invalid" then click LogOut, else Continue. You also need to record the error window.

  Was this answer useful?  Yes

Harish

  • Oct 18th, 2006
 

Assume vbscript is used in creating QTP scripts.

Use On Error Resume Next as the error handling statement. Exceptional handling in vbscript is done using the above statement and the same holds good even for QTP script.

The sample snippet gives you information about the error that is caused when we are trying to click on a webbutton that isn't existing

On Error Resume Next

Browser("<browser>").Page("<page>").WebButton("Save").Click

If Err.Number <> 0 Then

    MsgBox Err.Description

End If

On Error GoTo 0

  Was this answer useful?  Yes

I want to add something to the answer of Harish:

QTP uses Recovery Scenario Manager to implement error handling

Recover Scenario Manager uses 4 triggers to implement error handling:

1. Pop-Up Trigger: Used to track the exception due to Pop-up window appeared

2. Object State Trigger: Used to check the exception due to the change in the state of the object

3. Test Run Error Trigger: Used to track the exception due to some faulty test script

4. Application Crash Trigger: This exception comes into figure when the application crash takes place

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions