I am using puppeteer in my node project to check the number of img tag under a div, and I plan to achieve this by getting the nodelist from DOM and convert it to array so that I can easily filter the information.
But just to try it out first, I want to access an element first instead of a nodelist.
I don't understand why the return value (that being assigned to carousellNodeList) is undefined. I've checked the value I passed into page.evaluate(), which is IDls('photoCarousell'), and it is correct : "#app > div > div:nth-of-type(2) > div > div:nth-of-type(2) > div > div:nth-of-type(4) > div:nth-of-type(2) > div > div:nth-of-type(9) > div > div > div"
async function getDOMImgCount(){
let carousellNodeList = await page.evaluate((photoCarousellStr:string)=>{
return document.querySelector(photoCarousellStr) as HTMLElement
}, IDls('photoCarousell'))
let nodeListArr = Array.from(carousellNodeList);
}