I'm using Phantomjs to detect errors/warnings on my pages by hooking console messages :
page.onConsoleMessage = function(msg, line, source) {
console.log(msg);
}
page.open(page.address, function (status) {
if (status !== 'success') {
console.log('Fail to load the address');
} else {
for(var i=0;i<page.errors.length;i++)
{
console.log(page.errors[i]);
}
}
phantom.exit();
});
It works fine with the errors, but it does not record the warnings. By errors and warnings, I mean what Chrome console displays in red/yellow.
Is there a way to do it in PhantomJS or is it browser-dependant ?
Edit : updated code