0

I am trying to download the embedded pdf from the following page using RSelenium: https://rac.anpad.org.br/index.php/rac/article/view/1479/1672

# Access the web page (this works fine):
library(RSelenium)
driver <- rsDriver(browser = "firefox")
remote_driver <- driver[["client"]]
remote_driver$navigate("https://rac.anpad.org.br/index.php/rac/article/view/1479/1672")

# Download pdf (this is the part not working)
button <- remote_driver$findElement(using = "css selector", "span:nth-child(1)") # this seems to be working
button$clickElement() # but nothing happens here

But nothing happens, not even an error. Can someone tell me what is wrong? Is there a problem with the css selector? Or maybe with Firefox settings? I appreciate any help!! The best solution would include being able to set the file name to be downloaded.

Obs: I made a similar question here (How to download embedded PDF files from webpage using RSelenium?), but since I got stuck in the download step, I decided to post a simpler problem.

1 Answers1

1

I was able to download the file by,

library(RSelenium)
driver <- rsDriver(browser = c("chrome"))

remDr <- driver$client
remDr$navigate("https://rac.anpad.org.br/index.php/rac/article/view/1479/1672")

remDr$findElement(using = "xpath",'/html/body/header/a[3]') -> downloadfile

downloadfile$clickElement()
Nad Pat
  • 3,129
  • 3
  • 10
  • 20
  • Thanks! The download worked for me too following your code. It also worked if I first select the iframe in the page: ```web.elem <- remDr$findElements(using = "css", "iframe") # get all iframes in the webpage``` ```sapply(web.elem, function(x){x$getElementAttribute("id")}) # see their names (there's only one)``` ```remote_driver$switchToFrame(web.elem[[1]]) # Select the first and only iframe``` ```button <- remote_driver$findElement(using = "xpath", "//*[@id='download']")``` ```button$clickElement() # download``` – Veronica Santana Sep 13 '21 at 21:10