Capturing JavaScript error in Selenium

0
0

Is there a way to capture errors occurring in the DOM in Selenium and probably flag the same as an error in the page?

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:

element abcd not found in the console.

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.

Is it possible to do something like this?

  • You must to post comments
0
0

Here is information on testing for js errors.

http://www.silverwareconsulting.com/index.cfm/2010/6/7/Checking-for-JavaScript-Errors-with-Selenium

Put this script on your page and then check in Selenium for the JSError:

<script type="text/javascript">
window.onerror=function(msg){
$("body").attr("JSError",msg);
}
</script>
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website