title: Capturing JavaScript error in Selenium
body: <p>Is there a way to capture errors occurring in the <code>DOM</code> in <code>Selenium</code> and probably flag the same as an error in the page?</p>
  
  <p>To give  a brief example, let's say I'm trying to bind an event on a non-existing HTML control, my browser throws an error saying: </p>
  
  <p><code>element abcd not found in the console.</code></p>
  
  <p>Now, if I want the same error to fail my selenium tests and the message that is shown on the browser is shown as the error message.</p>
  
  <p><strong>Is it possible to do something like this?</strong></p>