Forum Discussion
How do you get the keyword test to raise an exception? The Test Complete 'errors' don't seem to trigger JavaScript errors; I have an error being thrown from the onLogError handler, but the catch block in the test runner routine seems to be ignored. I have read elsewhere that if the error is raised in another unit the error will be unable to be caught. If it was the keyword test itself raising the exception, I could see that working.
We actually wrote a little piece of code in JavaScript that we call anytime we want to raise an exception... simply a function that looks like this:
function throwError(errorText){ Log.Error(errorText); throw Error(errorText); }
Call this as a script routine in your keyword test and it will throw the exception which will bubble up through your framework code to your handling routines.
- KJM_VSA7 years agoNew Contributor
I tried that out and it appears to work; by just throwing an error directly from the keyword test, it seems to make it back to the original eval expression.
Unfortunately, It appears that I can't get errors to propagate from the onLogError handler. If I try to throw an error from the handler, the error gets logged, but will not hit the catch block associated with the eval expression. I was hoping this could be done to catch unexpected errors such as objects not being found, halt the test and move onto the next one. I'm not sure how you could integrate this into the keyword test itself.
I appreciate your help with this.
- tristaanogre7 years agoEsteemed Contributor
Unfortunately, object not found errors don't raise as an exception. However, depending upon how your test is constructed, you can add checks after you search for an object and raise your own exception if the object is not found (if object exists, for example).
Related Content
- 2 months agoSahall0308
- 6 months agonastester
Recent Discussions
- 2 hours agoSubhraDas
- 21 hours agotramuntana