Trang web này sẽ có chức năng hạn chế trong khi chúng tôi trải qua bảo trì để cải thiện trải nghiệm của bạn. Nếu một bài viết không giải quyết được vấn đề của bạn và bạn muốn đặt câu hỏi, chúng tôi có cộng đồng hỗ trợ của chúng tôi đang chờ để giúp bạn tại @FirefoxSupport trên Twitter và /r/firefox trên Reddit.

Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Tìm hiểu thêm

Config to automatically save pdf (or other mime types)

more options

I would like to use firefox to download several pdfs using selenium. To do so, I need to make firefox save pdfs automatically, without asking for confirmation. I duckduckgo-ed the issue (1, 2, 3, 4), but couldn't find an up-to-date working solution.

I tried to initialize a firefox profile and set the following prefs: ``` "browser.download.dir": dir, "browser.helperApps.neverAsk.saveToDisk": "application/pdf", "browser.download.manager.showWhenStarting": False, "browser.download.folderList": 2, ```

But firefox seems to ignore those and wants to display the pdf internally. If I force `"pdfjs.disabled": true`, I get again the download manager pop up. I can edit the preference in "about:preferences" to make firefox automatically download pdfs ([https://support.mozilla.org/en-US/kb/.../change-firefox-behavior-when-open-file]), but I cannot find a way to script this.

So, which are the about:configs to make firefox automatically download pdfs?

I would like to use firefox to download several pdfs using selenium. To do so, I need to make firefox save pdfs automatically, without asking for confirmation. I duckduckgo-ed the issue ([https://yizeng.me/2014/05/23/download-pdf-files-automatically-in-firefox-using-selenium-webdriver/ 1], [https://intellipaat.com/community/12473/downloading-file-to-specified-location-with-selenium-and-python/ 2], [https://stackoverflow.com/questions/46435978/downloading-pdf-with-selenium-webdriver-for-firefox/ 3], [https://stackoverflow.com/questions/36309314/set-firefox-profile-to-download-files-automatically-using-selenium-and-java 4]), but couldn't find an up-to-date working solution. I tried to initialize a firefox profile and set the following prefs: ``` "browser.download.dir": dir, "browser.helperApps.neverAsk.saveToDisk": "application/pdf", "browser.download.manager.showWhenStarting": False, "browser.download.folderList": 2, ``` But firefox seems to ignore those and wants to display the pdf internally. If I force `"pdfjs.disabled": true`, I get again the download manager pop up. I can edit the preference in "about:preferences" to make firefox automatically download pdfs ([[https://support.mozilla.org/en-US/kb/change-firefox-behavior-when-open-file|https://support.mozilla.org/en-US/kb/change-firefox-behavior-when-open-file]]), but I cannot find a way to script this. So, which are the about:configs to make firefox automatically download pdfs?

Tất cả các câu trả lời (1)

more options

Does selenium use a predefined profile?

The setting to always save files served with the Content-Type "application/pdf" is stored in the handlers.json file. This file appears to override the legacy neverAsk preferences based on a quick glance at the source code.

Note: If you do not control the server from which you are opening PDFs, one potential problem would be if the server uses a different Content-Type. Some servers send the generic "application/octet-stream" while others may improvise. Firefox will give you the dialog for unknown binary content types.