I’m looking for a way to use console.log within the context of page.evaluate. Specifically, how can I send log information back to the Node.js environment while the evaluation is occurring? My goal is to track the progress of the page.evaluate function and display certain results to the user effectively.
hey, you could try using window.addEventListener inside the page.evaluate function and then trigger a custom evennt with your log message. On the Node side, use page.on to listen for the event and log it. It might help in sending log back more easily.
hey emma, another approach could be to expose a function from Node.js using page.exposeFunction, and then calling that function from inside your page.evaluate script whenever you want to log something. the exposed function can log to console in the node env.