phantomjs page.evaluate not logging onto console

前端 未结 5 597
梦如初夏
梦如初夏 2020-12-29 20:54

I am a PhantomJs newbie. Just checked a similar post on this site. My question is why \'foo\' is not logged to console or printed?

var page = require(\'webpa         


        
5条回答
  •  囚心锁ツ
    2020-12-29 21:20

    There were some problems in the past with console logging, but with the current version on phantomjs (1.9.8), you can do:

    page.onConsoleMessage = function (msg) {
      console.log(msg);
    };
    

    then fire away your console.logs in the evaluate's callback:

    page.evaluate(function() {
      console.log("some logged message");
    });
    

提交回复
热议问题