I have extracted the text from the Name column of an HTML table using XPATH, which corresponds to column index [1]. Now, I need to navigate to the 3rd column with index [3] using XPATH, but I'm not sure how to proceed.
Here is my current XPATH:
//table[@id="analysis_reports_ct_fields_body"]//span[contains(text(), "Matches")]
In the HTML snippet provided below, the text "View" is located in the 3rd column. However, I cannot rely on the text "View" as it is sometimes blank.
The HTML snippet:
<table id="analysis_reports_ct_fields_body" cellspacing="0" style="table-layout: fixed; width: 100%;">
<colgroup>
<tbody>
<tr class="GLKP2TGBFG" __gwt_subrow="0" __gwt_row="0">
<td class="GLKP2TGBEG GLKP2TGBGG GLKP2TGBHG">
...
</td>
<td class="GLKP2TGBEG GLKP2TGBGG">
...
</td>
<td class="GLKP2TGBEG GLKP2TGBGG">
...
</td>
...
</tr>
...
</tbody>
</table>
When I use the XPATH below, it highlights various sections of the table:
//table[@id="analysis_reports_ct_fields_body"]//span[contains(text(), "Matches")]//ancestor::div
Is there a way to utilize the ancestor axis to reach the 3rd column? I attempted using //descendant::*, but it did not highlight anything. I believed that descendant moves down the tree, while ancestor moves up.
//table[@id="analysis_reports_ct_fields_body"]//span[contains(text(), "Matches")]//descendant::*
In my method, I will have a parameter called Name (representing column 1 of the table where "Matches" is found), and from there, I aim to locate the 3rd column within the table.
Best Regards, Riaz