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

129
Views
Cannot select element using Puppeteer

I'm using puppeteer to scrape some data off of a website, but all of my selections for a certain element are always undefined.

    const tempFunction = await page.evaluate(() => {
        let a = document.querySelectorAll(".flex.flex-wrap.w-100.flex-grow-0.flex-shrink-0.ph2.pr0-xl.pl4-xl.mt0-xl.mt3")
        let container = document.querySelector(".flex.flex-wrap.w-100.flex-grow-0.flex-shrink-0.ph2.pr0-xl.pl4-xl.mt0-xl.mt3")
        let b = container.getElementsByClassName("mb1 ph1 pa0-xl bb b--near-white w-33")
        return b
    })

For some reason this code always returns undefined, but similar code works fine.

    const checkData = await page.evaluate(() =>{
        let tempArray = []
        let element = document.querySelectorAll('.weather-block')
        
        tempArray.push(element[0].innerText)  
        return tempArray
    })

Even when trying to use specific selectors or id's, I only get undefined. Not sure where to go from here.

about 4 years ago · Santiago Gelvez
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!