Xpath: select div that contains class AND whose specific child element contains text

后端 未结 4 1824
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-13 04:02

With the help of this SO question I have an almost working xpath:

//div[contains(@class, \'measure-tab\') and contains(., \'someText\')]

Ho

4条回答
  •  一整个雨季
    2020-12-13 04:36

    You can change your second condition to check only the span element:

    ...and contains(div/span, 'someText')]
    

    If the span isn't always inside another div you can also use

    ...and contains(.//span, 'someText')]
    

    This searches for the span anywhere inside the div.

提交回复
热议问题