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

128
Views
How to select element with puppeteer?

I am trying to select this element with puppeteer: Text, using this code:


        const items =  document.querySelectorAll(".s-item")

    for (const item of  items) {
        list.push(
            {
                title: item.querySelector(".s-item__title").innerText.includes('2/102'),    
                price:   item.querySelector(".s-item__price").innerText.replace('$', ''),
                date: item.querySelector(".s-item__title--tagblock").innerText.replace("o", "")
            }
        )
    }

However, I get back an error message saying "Cannot read properties of null (reading 'replace')" From the "date" property.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can do a null check before applying replace string method to DOM select statement : item.querySelector(".POSITIVE")

ie: date: item.querySelector(".POSITIVE")? item.querySelector(".POSITIVE").replace("o", ""):""

about 4 years ago · Juan Pablo Isaza Report
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!