Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
Returning a node from puppeteer page.evaluate()

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);
                    
                }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!