Phantomjs page.onConsoleMessage doesn't log warnings

匿名 (未验证) 提交于 2019-12-03 09:52:54

问题:

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

回答1:

So after many research, it appears that the errors/warnings are browser-dependant (JS engine dependant to be exact).



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!