Search code examples
rseleniumselenium-firefoxdriverrselenium

How to allow multiple file types direct download (bzip2 and csv) in RSelenium


The following snippet allows us to perform direct download only for bzip2 file:

require(RSelenium)
dirdownload <- "/path_to/my_output_dir"
fprof <- makeFirefoxProfile(list(browser.download.dir = dirdownload,
                                 browser.download.folderList = 2,
                                 browser.download.manager.showWhenStarting = FALSE,
                                 browser.helperApps.neverAsk.saveToDisk = "application/x-bzip2"))
RSelenium::startServer()
remDr <- remoteDriver(extraCapabilities = fprof)

Especially this line:

browser.helperApps.neverAsk.saveToDisk = "application/x-bzip2"

How can I allow makeFirefoxProfile to include application/bzip2 and text/csv files?

I tried this but failed:

browser.helperApps.neverAsk.saveToDisk = c("application/x-bzip2", "text/csv")

Solution

  • This should do it:

    browser.helperApps.neverAsk.saveToDisk = "application/x-bzip2,text/csv,text/plain,application/json,application/zip"
    

    It should work as a comma separated list within the double quotes