When I run a puppeteer script , if I want to do a log inside the page.evaluate I can use a code like bellow
page.on('console', consoleObj => console.log(consoleObj.text()));
Unfortunately , it does not work if I want to log an object:
For example the code below does not log properly a js obj:
page.on("console", log => {
console[log._type](log.text());
});
await pageBis.evaluate(() => {
let selector = `select.form1 option[value="optionToSelect"]`;
let optionObj = document.querySelectorAll(selector)[0];
console.log(`optionObj : ${JSON.stringify(optionObj)}`);
});
It displays :
optionObj : {}
Do you know how to handle it please?