Skip to content

Instantly share code, notes, and snippets.

@robsquires
Created September 6, 2013 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robsquires/6458268 to your computer and use it in GitHub Desktop.
Save robsquires/6458268 to your computer and use it in GitHub Desktop.
code snippets to aid error diagnosis when using phantomjs
catching uncaught JS errors
//put this in your <head>
<script type="text/javascript" >
window.jsErrors = [];
window.onerror = function() {
window.jsErrors[window.jsErrors.length] = arguments;
}
</script>
//put this in your @afterStep method
$this
->getSession()
->getDriver()
->evaluateScript('return window.jsErrors')
);
catching networking errors
//run phantom js as follows
phantomjs -w --debug=true 2>&1 | tee >(grep Network) >/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment