download file with Rselenium & docker toolbox
If you are using Docker toolbox with windows you may have issues mapping volumes see Docker : Sharing a volume on Windows with Docker toolbox
If you are using Docker Machine on Mac or Windows, your Docker daemon has only limited access to your OS X or Windows filesystem. Docker Machine tries to auto-share your /Users (OS X) or C:\Users (Windows) directory.
I initiated a clean install of docker toolbox on a windows 10 box and ran the following image:
$ docker stop $(docker ps -aq)$ docker rm $(docker ps -aq)$ docker run -d -v //c/Users/john/test/://home/seluser/Downloads -p 4445:4444 -p 5901:5900 selenium/standalone-firefox-debug:2.53.1
NOTE: we mapped to a directory in the Users/john space. User john is running docker toolbox
Running the below code
require(RSelenium)fprof <- makeFirefoxProfile(list(browser.download.dir = "home/seluser/Downloads" , browser.download.folderList = 2L , browser.download.manager.showWhenStarting = FALSE , browser.helperApps.neverAsk.saveToDisk = "application/zip"))remDr <- remoteDriver(browserName = "firefox",remoteServerAddr = "192.168.99.100",port = 4445L,extraCapabilities = fprof)remDr$open(silent = TRUE)remDr$navigate("https://www.chicagofed.org/applications/bhc/bhc-home")# click year 2012webElem <- remDr$findElement("name", "SelectedYear")webElems <- webElem$findChildElements("css selector", "option")webElems[[which(sapply(webElems, function(x){x$getElementText()}) == "2012" )]]$clickElement()# click required quarterwebElem <- remDr$findElement("name", "SelectedQuarter")Sys.sleep(1)webElems <- webElem$findChildElements("css selector", "option")webElems[[which(sapply(webElems, function(x){x$getElementText()}) == "4th Quarter" )]]$clickElement()# click buttonwebElem <- remDr$findElement("id", "downloadDataFile")webElem$clickElement()
And checking the mapped download folder
> list.files("C://Users/john/test")[1] "bhcf1212.zip">
finally i have decided to make a clean install of the docker for windows (17.03.0) stable.i needed to decrease the number of available cpu (to 1) and available ram too (to 1GB).i have shared my c too (btw it s mandatory to have a password session otherwise you can't share the directoryafter that i restarted my computerOn the R side , do not forget to remove the: remoteServerAddr = "192.168.99.100"and i got the file.