使用 RSelenium 查找 element/elements

Finding element/elements using RSelenium

我正在尝试使用 findElement

在该网站上找到一个单一元素

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

例如"Display length".

稍后我想使用 findElements 查找所有元素。即 "Display length", ..., "Function callback"。共5个

我试图找到第一个元素(显示长度):

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

我试图找到几个元素:

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
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"