RSelenium
RSelenium copied to clipboard
Missing vignettes for uploading and downloading files
Hope these are useful:
Upload a file
uploadFile <- function(inputElement, path) {
# This is because Shiny hides the native browser file upload element, and shows a more user
# friendly one. So we first force the browser to display the hidden element.
inputElement$setElementAttribute("style", "display: inline")
inputElement$sendKeysToElement(list(text))
inputElement$sendKeysToElement(list(key = "enter"))
}
Download a file
webDriver <- RSelenium::remoteDriver(
browserName = "firefox",
extraCapabilities = RSelenium::makeFirefoxProfile(list(
"browser.download.dir" = "/some/path/on/your/computer/",
# This is an enum, '2' means use the value in the browser.download.dir parameter
"browser.download.folderList" = 2L,
"browser.helperApps.neverAsk.saveToDisk" = "text/csv"
))
)
webDriver$findElement("css", "#myDownloadLink")$clickElement()
# You can then check the file is as expected by looking in the dir you set earlier