Issue
I have the following HTML table in a page:
<table>
<tbody>
<tr>
<th>Birth Date</th>
</tr>
</tbody>
</table>
I have the following Xpath:
//table[//th[contains(text(), "Birth Date")]]/tr
I get rows from all tables in the page, not the one with the Birth Date
header.
What am I missing?
Solution
If I understand what you want then I think you are close. I think you want
'//table[.//th[contains(text(), "Birth Date")]]//tr'
(note the .
before //th
to query with respect to the table rather than the entire document).
You could also write this as
'//table[contains(.//th/text(), "Birth Date")]//tr'
Answered By - tomjn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.