You're targeting the text within the <div>
instead of the text within the <a>
, if I understand your goal correctly.
Try using //div[@class='form-item' and contains(a/text(),'@')]/a/text()
instead, as this will search the child <a>
element within the <div>
and not its parent.