[Question] How to manually download file (donwload dialog) ?
See original GitHub issueconst { chromium } = require("playwright");
const path = require("path");
(async () => {
const browser = await chromium.launch({
headless: false,
// downloadsPath: path.join(__dirname, 'downloads')
});
const context = await browser.newContext({
acceptDownloads: true,
});
const page = await context.newPage();
await page.goto('https://file-examples.com/index.php/sample-documents-download/sample-xls-download/');
// how to manually download file by User click ????
// // Automatic Download
// const handles = await page.$$("#table-files td.text-right.file-link");
// for (let num of handles) {
// const [download] = await Promise.all([
// page.waitForEvent('download'),
// num.click("a.btn")
// ]);
// await download.saveAs(path.join(__dirname, 'downloads', download.suggestedFilename()));
// }
// await browser.close();
})();
How to manually download file (donwload dialog) ?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
How does one get the file download dialog box back after you ...
Tools (IE Menu Bar) >View downloads, remove (X on the right) any downloads of the affected file type. Next time you encounter that...
Read more >Download File Dialog - selenium - Stack Overflow
I am using a variety of browsers (ruling out the automatic downloads as some browsers do not support this). I am using a...
Read more >Download a file from a search dialog and naming it from one ...
Is there a way to Automatically name a document while downloading it from one of the fields, like the Last_Name field? My customer...
Read more >how do i add "save as" to download's dialog box
i would like to be able to specify the name of the file that i am downloading right as i am downloading it,...
Read more >Download a file - Computer - Google Chrome Help
See a list of files you've downloaded · On your computer, open Chrome. · At the top right, click More More and then...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am experiencing the identical issue. My use case is I need to download a pdf file to be able to query the contents. In a similar way as ruslanx3m needed to use an xls file Some download options (such as save a pdf), when you open a pdf in a browser (Chrome), launch a native file dialog that needs accepting before the download can progress, rather than using the in browser download option, because the download hasn’t technically started at that point and an event hasn’t been created a ‘download’ object can’t be created, but one is needed to set the path for the download.
In my case I was able to awkwardly work round, by determining the URL of the file I needed to download and separately doing a fetch to that url and saving the Buffer from the response to a file. However it would have been much easier to be able to use a the ‘Download’ functionality.
@Ciantic I used axios (https://www.npmjs.com/package/axios) to perform the request as it writes out to a stream I could buffer into a file
const DownloadFileFromURL = async (url,path) => { const writer = Fs.createWriteStream(path) const response = await axios({ url, method: ‘GET’, responseType: ‘stream’ })
}