I'm using selenium to get some text on my webpage using xpath.
The page tag structure is as follows -
<span id="data" class="firefinder-match">
Seat Height, Laden
<sup>
<a class="speckeyfootnote" rel="p7" href="#">7</a>
</sup>
</span>
If I use the following code -
driver.findElement(By.xpath("//span[@id='data']")).getText();
I get the result = Seat Height, Laden 7
But I want to avoid reading the text within the <sup> tags and get the
result Seat Height, Laden
Please let me know which xpath expression I can use to get my desired result.
//span[@id='data']/text()[1]. One possible solution I can think of uses JS, the second gets the whole text and then deletes everything from child elements. Both solutions are rather ugly and I would like to see a nicer one. Anyway, if there's no answer in some reasonable short time, I'll post it.