I am trying to do some test using Selenium and I am facing some problems.
Suppose I have the following:
<p>
<label for="something">whatever :</label>
what I really want
</p>
I would like to be able to get only text what I really want, instead of all texts inside p-element
Getting text inside label is possible by doing :
selenium.getText("//p/label[@for='something']");
Does anyone know how to get only in my case “what I really want”
Thanks!
//p[label[@for = 'something']]/text()[normalize-space()]is an XPath expression selecting a node-set (XPath 1.0) or sequence (XPath 2.0) of direct text child nodes of thatpelement. In your sample there is only one such child node.