Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have created a framework where all the WebDriver API resides and in other project I am just calling those test cases I have created but the problem is that if anything goes wrong in the test case I would like to capture the error but instead currently I am just getting output failed

so my question is what is the best way of capturing error messages?

share|improve this question
Just to be clear, do you want to catch exceptions thrown by WebDriver OR are you looking to handle your test failures gracefully? – Suchit Parikh Oct 19 '12 at 23:49
Also see if this question is in the line of yours? --… – Suchit Parikh Oct 19 '12 at 23:50
Do you use Assertons at all? I do this alot in my test cases especially for debugging when writing them and often leave them in place for use later in case I get unexplained errors later on then I just uncomment, build and run the test to see what has changed – MichaelF Oct 26 '12 at 11:55

Depending on the implementation of your "other project" I would suggest that;

  • Change the external project to throw exceptions in the event of failure
    • Include a helpful error message, and some context about the current state of the method
  • Implement a post-test screenshot capture
    • We've implemented a JUnit Rule which extends TestWatchMan that runs after a test completes (for any case) and captures a screenshot from the remote server (base64 encoded png) and stores it with a filename like : ERROR-com.example.package.ClassName-myTestMethod.png which is kept by Jenkins for later review

If you want control in a programatic manner, go with the first option, if its for context of a failure, use the second.

Preferably, use both :-)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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