'Using findElements() in the RSelenium package to select multiple dropdown items and using clickElement()

I am trying to use clickElements() from the RSelenium package in order to drop down all of the downwards facing arrows in the "distrito" dropdown panel. I can do it for one of the dropdowns but I want to do it for all of them.

How can I click all of the dropdown items?

rD <- rsDriver(browser="firefox", port=4536L)
remDr <- rD[["client"]]
url2 = "https://www.fotocasa.es/es/comprar/viviendas/barcelona-capital/todas-las-zonas/l"
remDr$navigate(url2)
remDr$maxWindowSize()

# accept cookies
remDr$findElement(using = "xpath",'/html/body/div[1]/div[4]/div/div/div/footer/div/button[2]')$clickElement()
#click on Distrito
remDr$findElement(using = "xpath", '/html/body/div[1]/div[2]/div[1]/div[3]/div/div[1]/div')$clickElement()

remDr$findElement(using = "class name", 'sui-MoleculeCheckboxField-toggleIcon')$clickElement()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source