I am trying to figure out how to download a file using R / RSelenium. Information:
- OS: Win 8.1, RSelenium_1.7.1, with the image of dockers (linux, standalone-chrome 3.2.0).
I tried the top comment from this SO question:
How to upload a 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 does not work.
Any help is appreciated.
Edit
I think this should work, but I see an error while viewing the screenshot:
default win_sharedefault sudo mkdir vm_sharewin_share vm_share sudo mount -t vboxsf win_share vm_share. ( ssh default).- vm_share
/home/docker/vm_share
script . (. )
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")
x <- data.frame(a = 1:4, b = 5:8, c = letters[1:4])
write.csv(x, file = "testcsv.csv", row.names = FALSE)
path <- "/home/docker/vm_share/testcsv.csv"
webElem$sendKeysToElement(list(path))
remDr$close()
remDr$closeServer()
