Reputation: 389
I'm trying to collect data by saving the objects as PDF's using Selenium in R. I'm having some issues when reaching to the print-dialog window. My strategy has been to try to skip the print prompt/dialog but I can't get it to work. I tried this:
cprof <- list(
chromeOptions =
list(prefs = list(
'profile.default_content_settings.popups' = 0L,
'download.prompt_for_download' = FALSE,
'download.default_directory' = 'C:\\Users\\User\\Documents\\Text',
'download.directory_upgrade' = TRUE,
'plugins.plugins_disabled" = 'Chrome PDF Viewer',
'print.prompt' = FALSE
)
)
)
But the print dialog/prompt is still there. I know one way is to make the browser to be in kiosk-mode but I haven't found a way to do this in R (there are several threads about how to do it in Java or Python).
Thanks in advance!
Upvotes: 0
Views: 630
Reputation: 21
I needed to figure this out, as well. Based on these docs (see the "args" entry in the "Recognized capabilities" section, which references these additional docs), the following worked for me:
eCaps <- list(
chromeOptions =
list(args = list('--kiosk-printing')))
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4445L,
browserName = "chrome", extraCapabilities = eCaps)
Then, once you open a window with the PDF you want to save, the following automatically saves it to your specified download directory without any additional prompts:
remDr$findElements('css selector', 'html')[[1]]$sendKeysToElement(list(key='control', 'p'))
Upvotes: 2