RSelenium on docker: where are files downloaded? RSelenium on docker: where are files downloaded? docker docker

RSelenium on docker: where are files downloaded?


The docker container is a separate entity to the HOST which is running it. You need to map a directory on the HOST to a directory on the container you download files to:

You can do this when starting your container:

docker run -d -p 4445:4444 -p 5901:5900 -v /home/john/test:/home/seluser/Downloads selenium/standalone-firefox-debug:2.53.1

Here (i am running docker on linux) I have mapped a directory on my linux HOST (/home/john/test) to a directory on the container (/home/seluser/Downloads).

We then need to add the necessary information to the firefox profile:

library(RSelenium)ePrefs <- makeFirefoxProfile(  list(    browser.download.dir = "/home/seluser/Downloads",    "browser.download.folderList" = 2L,    "browser.download.manager.showWhenStarting" = FALSE,    "browser.helperApps.neverAsk.saveToDisk" = "multipart/x-zip,application/zip,application/x-zip-compressed,application/x-compressed,application/msword,application/csv,text/csv,image/png ,image/jpeg, application/pdf, text/html,text/plain,  application/excel, application/vnd.ms-excel, application/x-excel, application/x-msexcel, application/octet-stream"))remDr <- remoteDriver(extraCapabilities = ePrefs, port = 4445)remDr$open()remDr$navigate("http://www.colorado.edu/conflict/peace/download/")firstzip <- remDr$findElement("xpath", "//a[contains(@href, 'zip')]")firstzip$clickElement()

We can check if the download is on the HOST machine:

> list.files("/home/john/test/")[1] "peace.zip"