Skip to content

Instantly share code, notes, and snippets.

@arbaaz
Created February 6, 2015 14:20
Show Gist options
  • Save arbaaz/6fc195ec9fc0db40dbcd to your computer and use it in GitHub Desktop.
Save arbaaz/6fc195ec9fc0db40dbcd to your computer and use it in GitHub Desktop.
phantom js log console.log messages in terminal of url
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