I'm trying to select a certain checkbox using the link below. I've managed to find the checkbox using the findelements
command, however the problem is that I can't actually use the elements I found with the findelements
command to click on an element. The problem seems to be that the findelements
command outputs a list which is unusable if you unlist
it as a character, as it loses its "object containing active binding" schtick.
I don't really know what to make of this and how to solve it, but it should be relatively easy, I can't imagine that it would be impossible to interact with an element found in a findelements
list, but every attempt, including something as simple as "elements[4]" doesn't seem to work.
remDr <- RSelenium::remoteDriver(remoteServerAddr = "localhost",
port = 4445L,
browserName = "chrome")
remDr$open()
remDr$navigate("http://chicagodemocracy.org/ChooseElection.jsp")
remDr$screenshot(display = TRUE)
elements<- remDr$findElements(using = 'name', "office")
checkbox<-elements[4]
checkbox$clickElement()
remDr$screenshot(display = TRUE)
html <- xml2::read_html(remDr$getPageSource()[[1]])
Try using xpath to find the elements directly. You can the 'value' depends on which checkbox you like to select