-
-
Save macbre/9f23f314d8a3ff69313b to your computer and use it in GitHub Desktop.
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 page = require('webpage').create(), | |
MSG_SCREENSHOT = '123screenshot123'; | |
page.onConsoleMessage = function(msg) { | |
if (msg === MSG_SCREENSHOT) { | |
page.render('screenshot.png'); | |
phantom.exit() | |
} | |
console.log('INFO: ' + msg); | |
}; | |
page.onError = function(msg, trace) { | |
console.log('ERROR: ' + msg); | |
trace.forEach(function(item) { | |
console.log(' ', item.file, ':', item.line); | |
}); | |
}; | |
page.open('http://www.example.com', function() { | |
page.evaluate(function(MSG_SCREENSHOT) { | |
console.log('Navigation Timing object: ' + typeof window.performance); | |
console.log("Loading perfmap.js.."); | |
var el=document.createElement('script'); | |
el.src='https://zeman.github.io/perfmap/perfmap.js'; | |
document.body.appendChild(el); | |
setTimeout(function() { | |
console.log("Triggering a screenshot..."); | |
console.log(MSG_SCREENSHOT); | |
}, 1000); | |
}, MSG_SCREENSHOT); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cool stuff, thanks !