3

I'm implementing an extension to QTP using the Web Extensibility Toolkit. If my JScript function that implements the QTP action encounters an error (e.g User gave wrong argument values), I want the QTP to stop the test execution and notify the user about the error. I want it to act as a normal error in QTP and ask if the user want to debug\retry\skip\stop execution.

How can I do it?

1 Answer 1

1

If you throw an exception with a string then the message you throw is presented in QTP like any other script error (StopRetrySkipDebug)

You should throw a JavaScript Error object so that QTP will be able to display a meaningful message:

throw Error("I'm sorry, Dave. I'm afraid I can't do " + action);
4
  • When I tried it, I got a message in the explorer saying that: An exception was thrown and not caught. Asking me if I want to debug it. After pressing no, I get the desired QTP message but the error description is still "An exception was thrown and not caught".
    – Eldad
    Aug 6, 2009 at 14:27
  • 1
    The exception from explorer is because you don't have Disable script debugging (Internet Exploere) checked (from Tools -> Internet Options -> Advanced) which is the recommended mode when working with QTP.
    – Motti
    Aug 6, 2009 at 14:58
  • With string variables (var e = "error"; throw e;), the whole JS file is not working. With String literals (throw "error";) I still get the same: Description: Exception thrown and not caught
    – Eldad
    Aug 6, 2009 at 15:16
  • That's strange, try it with throw "error"; as the only thing on that specific script line (it works for me).
    – Motti
    Aug 6, 2009 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.