I use the following piece of code to achieve the download of a file by making Puppeteer click the button that emits the event
await page._client.send(
'Page.setDownloadBehavior',
{
behavior: 'allow',
downloadPath: './temporal/files/',
},
);
It works pretty fine in a Mac OS machine, but it does nothing in a Windows one
The try/catch that wraps this block it doesn't catch anything, and when I use the headless: false
setting, it's proven to "download the file", but there is no file in all the hard drive
In case Windows API needs an absolute path, you can compose it with __dirname
and relative path.