One way that is potentially not very polluting is to collect any errors by adding something like this to the head (remember that this will override any onerror handler that you already have):
<script> window.errors = []; window.onerror = function(error, url, line) { window.errors.push(error); }; </script>
Then you can do something like:
page_errors = page.evaluate_script('window.errors')
and state that the array is empty. You could print errors otherwise ...
Note. It is important to add a scriptlet to the head (possibly like the first scriptlet / script tag), since it must be one of the first scripts to be run.
Adrian cb
source share