Selenium xpath selector based on the element text

I think this is what you are looking for

ul/li[contains(text(), "Second")]

and better still

ul/li[text() = 'Second']

Leave a Comment