LucianoGanga / simple-headless-chrome

Simple abstraction to use Chrome as a Headless Browser with Node JS
MIT License
217 stars 50 forks source link

Cannot get onConsole working #78

Open dk253 opened 7 years ago

dk253 commented 7 years ago

Howdy! I like you library.

I cannot seem to capture console messages from my web page. My web page has several console messages that I need to trap in order to trigger a screen capture. Everything else seems to be working great. If you could give me an example of "onConsole", that would propel me forward. Thanks!

devishreebalasubramanian commented 6 years ago

Hi, I have also tried to capture and save browser console messages in the text file using the following code. But this code not works. await mainTab.onConsole(async function(e){ console.log(e[0].value) fs.writeFileSync('postedtoday.txt', e[0].value , {"encoding":'utf8'}); }) I have log my test messages like this. console.log('test message'); I need to save test message in postedtoday.txt file.I can't understand the onConsole function work flow.Please help me to solve my issue.