What would a Selenium xpath selector be for the following HTML:
- First
- Second
- Third<
You can use like this:
//li[. = "Second"]
OR
//li[contains(., "Second")]
Here, contains
mean that you can match the partial text, so below one is also correct:
//li[contains(., "Seco")]
If you want to get by text
[.= 'Second']
or
[text() = 'Second']
By.xpath( "//li[contains(text(), 'Second')]" )
I think this is what you are looking for
ul/li[contains(text(), "Second")]
and better still
ul/li[text() = 'Second']