title: Can Selenium take a screenshot on test(Assert.assertEquals()) failure?
body: <p>I am new to Selenium, and I am stuck with Selenium taking screenshots when Assert equals fails. I am using TestNG.</p>
  
  <p>When testcase fails on server side, it needs to take a screenshot of a page, so that i can exactly know where it went wrong.</p>
  
  <p>I wrap the code in try catch block and in catch, I am taking a screenshot.</p>
  
  <p>The Screenshot feature is working when O see selenium issues such as, where the element not visible, Unable to click on an element. </p>
  
  <p>But this is failing for Assert.equals(). When Assert.assertEquals() fails, I am expecting it goes to catch and takes a screenshot. Can anyone please clarify my doubts?</p>
  
  <p>Below is the code snippet, how I am trying to achive this:</p>
  
  <pre><code>try {
  
  
  Assert.assertEquals(expected,actualoutput,message) //it fails
  
  }
  
  catch {
  Selenium taking screenshot  // iam not able to take screenshot
  }
  </code></pre>