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

171
Views
¿Esperar a que se completen todas las descargas con Puppeteer?

Intento usar el código de esta pregunta , pero no funciona.

El waitForFunction parece omitirse y no se evalúa.

Se muestra chrome://downloads/, el archivo aún se descarga y el script finaliza.

 const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch({ headless: false, slowMo: 100, // Uncomment to visualize test }); const page = await browser.newPage(); await page.goto('https://speed.hetzner.de/'); // Resize window to 1588 x 901 and await navigation await page.setViewport({ width: 1588, height: 901 }); // Click on <a> "10MB.bin" await page.waitForSelector('[href="10GB.bin"]'); await page.click('[href="10GB.bin"]'); dmPage = await browser.newPage() await dmPage.goto('chrome://downloads/') await dmPage.bringToFront() await dmPage.waitForFunction(() => { // monitoring the state of the first download item // if finish than return true; if fail click const dm = document.querySelector('downloads-manager').shadowRoot const firstItem = dm.querySelector('#frb0') if (firstItem) { const thatArea = firstItem.shadowRoot.querySelector('.controls') const atag = thatArea.querySelector('a') if (atag && atag.textContent === 'Show in folder') { return true } const btn = thatArea.querySelector('cr-button') if (btn && btn.textContent === 'Retry') { btn.click() } } }, { polling: 'raf', timeout: 0 }, // polling? yes. there is a 'polling: "mutation"' which kind of async ) console.log('finish') // await browser.close(); })();

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!