使用Selenium在Firefox中启用自动下载文件到特定路径

时间:2018-03-12 08:03:48

标签: java selenium firefox

我想使用Firefox(54.0.1 (32-bit))Selenium自动将文件下载到特定文件夹。现在我每次都要获取下载窗口,当我想下载文件(.pdf)并且路径始终是默认的(我想自定义它)。我尝试过的(serenity.properties):

browser.download.lastDir = C:\\Path\\To\\The\\File\\
browser.download.folderList = 2
browser.download.dir = C:\\Path\\To\\The\\File\\
download.prompt_for_download = false
browser.download.manager.showWhenStarting = false
browser.download.manager.addToRecentDocs = true
browser.download.manager.useWindow = false
browser.download.useDownloadDir = true
browser.download.show_plugins_in_list = true
browser.download.animateNotifications = false
browser.helperApps.neverAsk.saveToDisk = text/plain,application/octet-stream,application/pdf
browser.helperApps.neverAsk.openFile = text/plain,application/octet-stream,application/pdf
browser.helperApps.alwaysAsk.force = false
pdfjs.disabled = true
plugin.scan.Acrobat = 99.0
plugin.scan.plid.all = false
plugin.disable_full_page_plugin_for_types = application/pdf
pdfjs.enabledCache.state = false

例如在Chrome中,它适用于我的设置(serenity.properties

chrome_preferences.safebrowsing.enabled = true
chrome_preferences.download.default_directory = C:\\Path\\To\\The\\File\\
chrome_preferences.profile_default_content_settings.popups = 0

PS我已经尝试过很多来自互联网的建议,包括这个网站,但仍然没有运气。有什么建议吗?

0 个答案:

没有答案