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(); })();