Created
February 6, 2015 14:20
-
-
Save arbaaz/6fc195ec9fc0db40dbcd to your computer and use it in GitHub Desktop.
phantom js log console.log messages in terminal of url
This file contains hidden or 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
var args = require('system').args; | |
var page = require('webpage').create(); | |
var url = 'http://localhost:3000/central/src/index.html#'; | |
console.log('Loading a web page'); | |
if (args.length === 1) { | |
console.log('Try to pass some arguments when invoking this script!'); | |
phantom.exit(); | |
} else { | |
url = url + args[1]; | |
page.onConsoleMessage = function(msg) { | |
console.log(msg); | |
}; | |
page.open(url, function(status) { | |
window.setTimeout(function() { | |
page.render("dummy"); | |
phantom.exit(); | |
}, 1000) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment