How to print text from child node using xpath?

39 views
Skip to first unread message

rajpradeep32

unread,
Oct 2, 2015, 9:56:06 AM10/2/15
to Selenium Users
Using the below xpath am able to point to the text 'caught Hughes' in the HTML code but am unable to print it. Using Java in selenium webdriver

XPATH:
++++++
//*[@id='full-scorecard']/div[2]/div/table[1]/tbody/tr[3]/td[2]/child::text()


HTML:
+++++
<td colspan="8">
<b>12.6</b>
 caught Hughes 
<b>73/4</b>
<br/>
</td>


Thanks!

Dmitri T

unread,
Oct 4, 2015, 5:07:04 AM10/4/15
to Selenium Users
It is quite hard to produce a good XPath query without seeing the full HTML code, for the piece you posted you can try something like:

//b[text()='12.6']/parent::*/text()[2]

See the following references to learn about XPath syntax:

There is also quite good Firefox extension which provides visual information on your XPath query matches - XPath Checker
Reply all
Reply to author
Forward
0 new messages