html - XPath Text or Child Node -
i have div element on page used display error messages. div invisible unless populated.
unfortunately, content type inconsistent. in cases can have direct child text node, pick with:
contains(text(),'*'))
or can contain <span> contains own child text node, pick with:
//div/span[contains(text(),'*')]
as to, cannot change behaviour.
example 1:
<div id="toperrormessagediv">error message</div> example 2:
<div id="toperrormessagediv"> <span style="something">error message 1<br>error message 2</span> </div> fortunately, don't need know contents, need know if div non-empty.
can me out?
try one
//div[@id="toperrormessagediv" , .//text()] to match div contains text content
Comments
Post a Comment