I am working on a test case and need to find text within a table. The only thing to key off of is the label in the previous column. The keys are Next Trckng/Dschrg, Next Full, Next Qtrly, Next Mdcr. I would like to create an xpath expression that will find the Text 1, Text 2, Text 3, and Text 4 based on the key. Since all the keys have the word Next in them, I have mocked this up to find all four of them at once.
//td[preceding-sibling::td[contains(descendant::text(),'Next')]]/a
The third one is not found because it does not have an 'a' element, which is fine. the problem comes in the very first td. It has a span in it, unlike the others. The span is on a second physical line from the td. It appears that the CRLF is preventing FirePath from finding the first td, when I put the span on the same line as the td, it is found. The problem is that I cannot change the actual page, this is a test case.
Is this a FireBug issue or is this actually resulting in two text elements in the DOM? How do I tweak the xpath to find all four nodes?
Here is the HTML:
<table border=1>
<tbody>
<tr>
<td>
<span id="xxx"><a><img></a></span>
Next Trckng/Dschrg:</td>
<td><a>Text 1</a></td>
<td>Next Full:</td>
<td><a>Text 2</a></td>
<td>Next Qtrly:</td>
<td> <!-- Text 3 --></td>
<td>Next Mdcr:</td>
<td><a>Text 4</a></td>
<td>Change Of Therapy:</td>
</tr>
</tbody>
</table>