Reputation: 1036
In the website I am trying to select "English" language from the dropdown shown in top in the website. I am able to open the dropdown but value ('English') is not selected from the dropdown. I am very close but it seems missing something simple.
library(RSelenium)
library(xml2)
library(rvest)
# Docker
shell('docker run -d -p 4445:4444 selenium/standalone-chrome')
remDr <- RSelenium::remoteDriver(remoteServerAddr = "localhost",
port = 4445L,
browserName = "chrome")
remDr$open()
# Website
remDr$navigate("https://www.idealista.com/venta-viviendas/madrid-madrid/")
# Change Language Selector
webElem <- remDr$findElement(using='class', 'lang-selector')
webElem$getElementAttribute("class")
webElem$clickElement()
# change to English
webElem1 <- remDr$findElement(using = 'xpath', "//span[contains(@class,'lang-selected') and contains(text(),'English')]")
webElem1$clickElement()
Upvotes: 0
Views: 50
Reputation: 1166
Try this xpath
//*[@id='main-header']//a[@id='idioma-en']/span[normalize-space(contains(text(),'English'))]
Upvotes: 1