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

How to set download dir using puppeteer-extra-plugin-user-preferences #44

Closed
kailashkrish opened this issue Jun 5, 2019 · 5 comments
Closed

Comments

@kailashkrish
Copy link

puppeteer.use(require('puppeteer-extra-plugin-user-data-dir')()) puppeteer.use(require('puppeteer-extra-plugin-user-preferences')({prefs: { download: { prompt_for_download: false, default_directory: OUTDIR, } } })). This wasn't successful. Any idea to set download behaviour at browser level. Btw great wrapper for puppeteer.

@leblancmeneses
Copy link

This worked for me.

import * as UserPreferencesPlugin from 'puppeteer-extra-plugin-user-preferences';
puppeteer.use(UserPreferencesPlugin({
  userPrefs: {
    download: {
      prompt_for_download: false,
      default_directory: '/tmp',
    },
    webkit: {
      webprefs: {
        default_font_size: 22
      }
    }
  }
}));

@berstend
Copy link
Owner

berstend commented Dec 5, 2019

Assuming that what @leblancmeneses provided (thanks!) works I'm gonna close this issue now. :)

@berstend berstend closed this as completed Dec 5, 2019
@tlecoz
Copy link

tlecoz commented May 7, 2021

Unfortunately, it doesn't work for me and I'm becoming crazy...

@berstend
Copy link
Owner

berstend commented May 7, 2021

Unfortunately, it doesn't work for me and I'm becoming crazy...

try to make a small demo script and share it here or on https://extra.community

@uzair004
Copy link

uzair004 commented Jul 28, 2022

this worked for me, using puppeteer extra with a puppeteer-extra-plugin-user-preferences plugin

const UserPreferencesPlugin = require("puppeteer-extra-plugin-user-preferences");

const downloadImageDirectoryPath = process.cwd()

puppeteer.use(
  UserPreferencesPlugin({
    userPrefs: {
      download: {
        prompt_for_download: false,
        open_pdf_in_system_reader: true,
        default_directory: downloadImageDirectoryPath,
      },
      plugins: {
        always_open_pdf_externally: true,
      },
    },
  })
);

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

5 participants