Search code examples
rxpathrselenium

XPath in RSelenium: Find by text


Questions:

  • How can I find the element 1468 by it's text?
  • Why is is not working in the way that I tried it?

My approach:

For the below html code snippet,

HTML-Code

when I do

> t <- remDr$findElement('xpath', "//li[@data-iid = '1468']")
> t$getElementText()

I get

[[1]]
[1] "Handel"

However, when I now search for

> remDr$findElement('xpath', "//li[text() = 'Handel']")

Solution

  • Answer:

    remDr$findElement('xpath', "//li[. = 'Handel']") solves it.

    With text(), I don't get the bold text. RSelenium is misleading in this as it does not return the text() when I use getElementText(), it rather returns ..