• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

245
Views
Puppeteer - why is innerText not printed on console while every element does?

I'm trying to access innerText of a list of 8 els (elements).
When I map over els and console.log(el) I see 8 elements neatly printed in my console of browser.
But when I console.log(el.innerText) I am getting just 3 or 4 texts printed out in my console.

I don't understand, what is happening here?

  // wait for all cards to appear on page
  await page.waitForSelector(".card.cardItem:nth-of-type(8)", { timeout: 0 });

  await page.$$eval(".card.cardItem", (els) => {
    els.map((el) => {
      // logs out 8 elements (all have innerText on webpage).
      console.log(el)

      // logs out innerText of only 3 elements. Why?
      console.log(el.innerText);
    });
  });
about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I got it to work with using textContent instead. I don't understand why, but it works. I will keep question open as I'm still curious why innerText doesn't work here so if someone knows feel free to explain to us.

about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error