I am aware, that if I know the URL, then I can fetch a file to a variable like this:
await page.evaluate(() => {
return fetch(URL, {
method: "GET",
credentials: "include"
}).then(r => r.text());
});
My problem is, that there is no direct URL, just a button in the page which does some JS magic and then the download begins.
What code would trigger the download in this case via button click (no form)
UPDATE
This code works for download via button click:
await page._client.send('Page.setDownloadBehavior', {
behavior: 'allow',
downloadPath: '/home/domain.tld/tmp',
});
await page.click('#exportButton');
await page.waitFor(20000);
Is there a way to set the filename?
How can I do this without downloading the file, but fetch into a variable?
Thanks,