I am trying to find out how to upload a file using R/RSelenium. Informations:
- OS: Win 8.1, RSelenium_1.7.1, with a docker image (linux, standalone-chrome 3.2.0).
I tried the top comment from this SO question:
How to upload file using Selenium WebDriver in Java
Example:
url <- "https://www.freepdfconvert.com/pdf-word" path <- "C:/path_to_folder/filename.pdf" remDr$navigate(url) upload_btn <- remDr$findElement(using = "id", "clientUpload") upload_btn$sendKeysToElement(path) But I get the following error message:
Selenium message:java.lang.String cannot be cast to java.util.List Error: Summary: UnknownError Detail: An unknown server-side error occurred while processing the command. class: java.lang.ClassCastException Further Details: run errorDetails method The folder used is mapped to the virtual machine. Autoit is out of the question since it only works on Windows.
Also tried upload_btn$sendKeysToElement(list(path)) which does not return an error, but it is not working either.
Any help is appreciated.
Edit:
I think this is supposed to be working but I am seeing an error when viewing a screenshot:
- Mounted my working folder to the
defaultvirtual machine as a shared folder and named itwin_share - Created a folder on
defaultwithsudo mkdir vm_share - Mounted
win_shareto the foldervm_sharewithsudo mount -t vboxsf win_share vm_share. After this step I can successfully access my working folder on the virtual machine (checked bysshintodefault). - The path of vm_share folder is
/home/docker/vm_share
After all of these executing this script it doesn't work. (took John's example)
library(RSelenium) remDr <- remoteDriver(remoteServerAddr = "192.168.99.100" , port = 4445L , browserName = "chrome" ) remDr$open() remDr$navigate("https://gallery.shinyapps.io/uploadfile") webElem <- remDr$findElement("id", "file1") # create a dummy csv x <- data.frame(a = 1:4, b = 5:8, c = letters[1:4]) write.csv(x, file = "testcsv.csv", row.names = FALSE) # post the file to the app path <- "/home/docker/vm_share/testcsv.csv" webElem$sendKeysToElement(list(path)) remDr$close() remDr$closeServer() Screenshot:

paththis will not work.docker run -d -v vm_share:/home/docker/vm_share -p 4445:4444 selenium/standalone-chrome. This should then create a mapping between the boot2docker vm folder and the container folder/home/docker/vm_share. The vm folder itself already mapped to your windows host.