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
puppeteer queryselectorall returns a null result when I use a variable that changes in a for loop

I want to do a queryselectorall scrape with 35 different selectors that differ only in the number in the middle, after each scrape I want to mark where it started and ended.

When I try to replace part of the selector with the number that changes in the loop it returns null with

---- start ----

----- end ----- The selector works if there is no variable but a number between 0-35

When I replace selectors in a chrome console like this it works. Could it be that I'm making a mistake?, how to make it work in puppeteer?

//The usual stuff of puppateer....



var array = [];
for (let i = 0; i <= 35; i++) {


  const theopeninfo2 = await page.evaluate(() => {
    return Array.from(document.querySelectorAll("#accordion_wide_"+i+" > div > div.main > div:nth-child(1) > div.dynamic_cmp_wrapper.size_x2_3 > div.ad_additional_info_items_wide.dynamic_cmp.accordion_wide_theme > div.items_container > div:not(.delete)")).map( x=> x.innerText).join("\n")
})

let start = "----start----\n";
let end = "\n----end----";
let result_start = start.concat(theopeninfo2);
let result_start_end = result_start.concat(end);
array.push(result_start_end)
}
array = array.join("\n")
console.log (array)

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!