Created
September 6, 2013 01:03
-
-
Save robsquires/6458268 to your computer and use it in GitHub Desktop.
code snippets to aid error diagnosis when using phantomjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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