3

I am trying to find one singular element on this website using findElement

https://shiny.rstudio.com/gallery/datatables-options.html

For example "Display length".

Later I would like to find all elements using findElements. That is, "Display length", ..., "Function callback". Total of 5.

My attempt for just finding the first element (Display length):

remDr$navigate("https://shiny.rstudio.com/gallery/datatables-options.html")
elems <- remDr$findElement("css selector", "#showcase-app-container > nav > div > ul > li.active > a") 
# Unable to locate element 

elems <- remDr$findElement("xpath", "//*[@id='showcase-app-container']/nav/div/ul/li[1]/a") 
# Unable to to locate element

My attemp on finding several elements:

elems <- remDr$findElements("class", "nav navbar-nav") 
# Invalid or does not result in a WebElement

elems <- remDr$findElements("css selector", "#showcase-app-container > nav > div > ul") 
# list of 0

elems <- remDr$findElements("xpath", "//*[@id='showcase-app-container']/nav/div/ul") 
# list of 0
1
  • 3
    That content is in an iframe. Check you have switched to the relevant iframe. Commented Sep 4, 2017 at 19:51

1 Answer 1

9
remDr$navigate("https://shiny.rstudio.com/gallery/datatables-options.html")
# htmlParse(remDr$getPageSource()[[1]]) to first the frames (only 1)

webElems <- remDr$findElements("css selector", "iframe")

remDr$switchToFrame(webElems[[1]])

elems <- remDr$findElements("css selector", "#showcase-app-container > nav > div > ul li")

unlist(lapply(elems, function(x) x$getElementText()))

# "Display length"    "Length menu"       "No pagination"     "No filtering"      "Function callback"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.