Hello :) I'm trying to automate downloading spreadsheets from XYZ website. The code works well, goes through authorization without problem and downloads the file. But, when I try to change the download directory, it starts to download the file, but instantly gives me file download error in browser. The way I tried to change the download directory is by adding:
eCaps <- list(
chromeOptions =
list(prefs = list("profile.default_content_settings.popups" = 0L,
"download.prompt_for_download" = FALSE,
"directory_upgrade" = TRUE,
"download.default_directory" = "C:/XXX/YYY"
)
)
)
and adding the extraCapabilities = eCaps to rsDrive():
rD <- rsDriver(browser= "chrome", chromever = "80.0.3987.16", extraCapabilities = eCaps)
Without these two changes code worked well, downloading to default download directory. Is there any way to set it properly to download to any other directory?
Here is the complete code:
library(RSelenium)
eCaps <- list(
chromeOptions =
list(prefs = list("profile.default_content_settings.popups" = 0L,
"download.prompt_for_download" = FALSE,
"directory_upgrade" = TRUE,
"download.default_directory" = "C:/XXX/YYY"
)
)
)
rD <- rsDriver(browser= "chrome", chromever = "80.0.3987.16", extraCapabilities = eCaps)
remDr <- rD$client
appURL <- 'https://XYZ'
remDr$navigate(appURL)
remDr$findElement("id", "loginEmail")$sendKeysToElement(list("email"))
remDr$findElement("id", "loginPassword")$sendKeysToElement(list("password", key='enter'))
appURL2 <- "https://XYZ/XYZ"
remDr$navigate(appURL2)
remDr$navigate(appURL2)
remDr$findElement("link text", "XLSX")$sendKeysToElement(list(key='enter'))
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…