Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

page._client.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: './tmp/order'}) causing error #3473

Closed
emclab opened this issue Nov 1, 2018 · 3 comments

Comments

@emclab
Copy link

emclab commented Nov 1, 2018

I can download the file to the default subdir which is the download by.

await page.goto('https://www.mysite-com/admin/order?_export_=page%3A1');

However when I specified the download subdir with the following code, the file is still downloaded to the default subdir and with error:

await page._client.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: './tmp/order'});

The error is:

Error: net::ERR_ABORTED at https://www.mysite-com/admin/order?_export_=page%3A1
<     at navigate (C:\code\js\wbot\node_modules\puppeteer\lib\FrameManager.js:103:37)
<     at <anonymous>
<     at process._tickCallback (internal/process/next_tick.js:189:7)

Puppeteer is 1.9.0. Is it bug?

@aslushnikov
Copy link
Contributor

@emclab two things here:

We'll move to the proper downloads using response interception once #3471 is fixed; please follow #299 for the updates.

Sorry for the inconvenience!

@spadkins
Copy link

You might try using an absolute path instead of a relative path.

Also, I am running on Windows from a MinGW64 bash command line, but because the path was going to be passed to an instance of Chrome for Windows, I took care to pass an absolute path that looked right for Windows (e.g. "C:\dev\downloads" or whatever).

(Using process.cwd() along with the "path" npm module took care of the details for me.)
let dir = path.join(process.cwd(), "path", "to", "download", "dir");

@azazrehman
Copy link

azazrehman commented Feb 18, 2020

If there is error on file which you want to download then try this one:

const myDownloadPath = path.resolve(${Directory Where you want to download})
mkdirp(myDownloadPath)
await page._client.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: myDownloadPath });

imported:
const mkdirp = require('mkdirp')
const path = require('path')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants