Playwright: [Feature] Downloads

Created on 6 Feb 2020  路  5Comments  路  Source: microsoft/playwright

It would be nice to have an api like:

page.on('download', async download => {
   const buffer = await download.data();
   console.log('got download', download.url(), buffer.length);
});

We can hack it with Page.setDownloadBehavior in chromium and monitoring the download folder, but it would be nicer to have something like download interception in all of the browsers.

Should the event come when the download starts, or when it finishes? I think when it starts.

Previous discussion in puppeteer: puppeteer/puppeteer#299

Most helpful comment

I love the API!
However, I am really fine with just specifying the download directory without intercepting the request on its own. If I could have a file saved in a proper directory I can open it by myself once it is written and do all manipulations there.

It would be nice to have an event like donload.complete but I'm not sure where this event should be attached... Anyway, at this moment we can just monitor directory for a file and that's enough for us!

All 5 comments

@aslushnikov what do you think?

I love the API!
However, I am really fine with just specifying the download directory without intercepting the request on its own. If I could have a file saved in a proper directory I can open it by myself once it is written and do all manipulations there.

It would be nice to have an event like donload.complete but I'm not sure where this event should be attached... Anyway, at this moment we can just monitor directory for a file and that's enough for us!

@JoelEinbinder have you tried https://chromedevtools.github.io/devtools-protocol/tot/Page/#event-downloadWillBegin?

Believe that comment was for @JoelEinbinder instead 馃槃

Download event is now available.

Was this page helpful?
0 / 5 - 0 ratings