I am using Selenium using a docker image:
require(RSelenium)
if (length(system("docker ps -l", intern = TRUE))<2)
try({system("docker run -d -p 4445:4444 selenium/standalone-firefox:2.53.0")})
It works, I can connect to any url and navigate. However when I click a button to download a file, it sometimes saves it (partially, saved as xxxxxxx.csv.part
) to /tmp/mozilla_mozillaUser0
, and sometimes to ... nowhere, or maybe another location I cannot find...
Is there a reason for that?
Also I tried to open the driver using
makeFirefoxProfile(list(browser.download.dir = "D:/temp"))
but it returns a weird error
Error in file(tmpfile, "rb") : cannot open the connection
In addition: Warning messages:
1: running command '"zip" -r9Xjq "C:\Users\rocks\AppData\Local\Temp\RtmpoPhjUb\file31076202d4f.zip" "C:\Users\rocks\AppData\Local\Temp\RtmpoPhjUb/firefoxprofile/prefs.js" ' had status 127
2: In file(tmpfile, "rb") :
cannot open file 'C:\Users\rocks\AppData\Local\Temp\RtmpoPhjUb\file31076202d4f.zip': No such file or directory
where I can understand why this desn't work given that all links are in windows but my selenium runs in a docker container or Ubuntu.
My Setup: R running on Windows, and I have a docker image of Ubuntu that contains the selenium server.
EDIT: turns out my issue was because firefox was not installed on the host machine (which is not needed in theory).
I fixed the issue by using (instead of invoking makeFirefoxProfile
):
fprof = structure(list(firefox_profile = "UEsDBBQAAAAIANJiVEobimJN8QAAABkCAAAIAAAAcHJlZnMuanOFkT9PwzAQxXckvkOUCSQnlliZkDqygcSITHyJTW3fyXdNIj49btqBoLTd7t57v/OfOzDkT8rQP9RfGafStRanFNDY1vpcq6rWDiNohnDM6t3Z5frx+f7uGt5jsJBfPUuZ8nQrHU0yQxHY4fThIL2JyeLTUNjeBIYLvINAkF+IuE0wlor3LZsR3nHneX+8fjwE8VSG6bn58aQMUfCdEY9J/+tPiabDWA5hBrs2LxmRJ8xrqeNRCcyyFD6Wl2lKQ3UuvwkGVf3Nk+1VtQBOYjihFIxPqlrlYO4grNExlc/jZsOZt8XIGzJ2AtKwZDBx2ewvUEsBAj8AFAAAAAgA0mJUShuKYk3xAAAAGQIAAAgAJAAAAAAAAAAgAAAAAAAAAHByZWZzLmpzCgAgAAAAAAABABgAzaOo9TCL0gHdkgMtLYvSAd2SAy0ti9IBUEsFBgAAAAABAAEAWgAAABcBAAAAAA=="), .Names = "firefox_profile")
remDr <- remoteDriver(extraCapabilities = ePrefs, port = 4445)