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

149
Views
No se puede modificar el elemento con titiritero

Estoy tratando de hacer un bucle en la matriz de estudiantes y modificar los elementos html para imprimir una tarjeta para cada estudiante.

Sin embargo, el siguiente código falla en page.evaluate y da el siguiente error:

 Evaluation failed: ReferenceError: student is not defined
 (async () => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto(`file://${__dirname}/card/card.html`); console.log(students); for (const student of students) { console.log(student.name); await page.evaluate(() => { document.getElementById("name").innerHTML = student.name; document.getElementById("id").innerHTML = student.id; document.getElementById("text").innerHTML = student.text; }); await page.screenshot({ path: `example-${student.id}.png` }); } await browser.close(); })();
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El parámetro page.evaluate() se ejecuta en el contexto del navegador, por lo que debe transferir cualquier variable del contexto de Node.js explícitamente como argumentos y parámetros adicionales:

 await page.evaluate((student) => { document.getElementById("name").innerHTML = student.name; document.getElementById("id").innerHTML = student.id; document.getElementById("text").innerHTML = student.text; }, student};
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!