Selenium xpath selector based on the element text

后端 未结 4 544
小鲜肉
小鲜肉 2020-12-01 11:13

What would a Selenium xpath selector be for the following HTML:

  • First
  • Second
  • Third<
4条回答
  •  误落风尘
    2020-12-01 11:18

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

提交回复
热议问题