I have a working code where for a given URL I capture all elements with the same class name. There appear to be three, with different "ElementText" names.
My issue is that I would like to click one of these elements (clickElement), specifically the second one with the name "GET MORE DEPARTURES".
Could anyone kindly point me in the right direction of how to do this? I have managed to click the first element, however not how to click a specific element from a list.
Please see code below, and many thanks.
library(RSelenium) library(rvest)
# Download binaries, start driver, and get client object.
rd <- rsDriver(browser = "firefox", port = 1999L)
ffd <- rd$client
ffd$navigate(paste0("https://www.XXXXXX",sep=""))
load_btn <- ffd$findElements(using = "css selector", "button.md-raised.blue-md-button.md-primary.md-button.md-ink-ripple")
#getting list of element names from abobe
unlist(lapply(load_btn, function(x) x$getElementText()))
"MARS 12" "GET MORE DEPARTURES" ""
#My issue is here, how to I specify that I want to click the "GET MORE DEPARTURES" element?
load_btn$clickElements()