title: How to upload files with RSelenium?
body: <p>I am trying to find out how to upload a file using R/RSelenium. Informations:</p>
  
  <ul>
  <li>OS: Win 8.1, RSelenium_1.7.1, with a docker image (linux, standalone-chrome 3.2.0).</li>
  </ul>
  
  <p>I tried the top comment from this SO question:</p>
  
  <p><a href="https://stackoverflow.com/questions/16896685/how-to-upload-file-using-selenium-webdriver-in-java">How to upload file using Selenium WebDriver in Java</a> </p>
  
  <p>Example:</p>
  
  <pre><code>url &lt;- "https://www.freepdfconvert.com/pdf-word"
  path &lt;- "C:/path_to_folder/filename.pdf"
  
  remDr$navigate(url)
  
  upload_btn &lt;- remDr$findElement(using = "id", "clientUpload")
  upload_btn$sendKeysToElement(path)
  </code></pre>
  
  <p>But I get the following error message:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>The folder used is mapped to the virtual machine. <strong>Autoit</strong> is out of the question since it only works on Windows.</p>
  
  <p>Also tried <code>upload_btn$sendKeysToElement(list(path))</code> which does not return an error, but it is not working either.</p>
  
  <p>Any help is appreciated.</p>
  
  <hr>
  
  <p><strong>Edit</strong>:</p>
  
  <p>I think this is supposed to be working but I am seeing an error when viewing a screenshot:</p>
  
  <ul>
  <li>Mounted my working folder to the <code>default</code> virtual machine as a shared folder and named it <code>win_share</code></li>
  <li>Created a folder on <code>default</code> with <code>sudo mkdir vm_share</code></li>
  <li>Mounted <code>win_share</code> to the folder <code>vm_share</code> with <code>sudo mount -t vboxsf win_share vm_share</code>. After this step I can successfully access my working folder on the virtual machine (checked by <code>ssh</code> into <code>default</code>). </li>
  <li>The path of vm_share folder is <code>/home/docker/vm_share</code> </li>
  </ul>
  
  <p>After all of these executing this script it doesn't work. (took John's example)</p>
  
  <pre><code>library(RSelenium)
  
  remDr &lt;- remoteDriver(remoteServerAddr = "192.168.99.100" 
                                              , port = 4445L
                                              , browserName = "chrome"
  )
  remDr$open()
  remDr$navigate("https://gallery.shinyapps.io/uploadfile")
  webElem &lt;- remDr$findElement("id", "file1")
  
  # create a dummy csv 
  x &lt;- 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 &lt;- "/home/docker/vm_share/testcsv.csv"
  webElem$sendKeysToElement(list(path))
  
  remDr$close()
  remDr$closeServer()
  </code></pre>
  
  <p><strong>Screenshot</strong>:</p>
  
  <p><a href="https://i.stack.imgur.com/JVJwy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JVJwy.png" alt="Error"></a></p>