I have a table with 3 rows (tr's) and 3 columns (td cells).
About this table:
1.The columns are not fixed, and 1st column can be moved to 2nd column.
2.The manager column just contains a round box like img which will be checked (only one at a time).
Name Email Manager
Name1 email_id_1 roundbox (selected currently)
Name2 email_id_2 roundbox
Name3 email_id_3 roundbox
I was successful in getting the number of rows, number of columns, index of each column from the table.
List<WebElement> rows = tablelocator.findElements(By.path of rows locator)
print(rows.size)
But the next step is failing where in the element "Xpath of the selected manager" is not visible (not time / wait related issue).
WebElement rowWhichIWant = driver.findElement(By.xpath("path of row 1 whose manager is selected"));
The above fails with no such element (even though the row gets highlighted in the browser when searching with this locator, so its not a locator problem as well)
I want to retrieve only the email id of the currently selected manager, i.e email_id_1.
HTML:
<div tabindex="0" id="somename">
<table class="x1ns" summary="some summary">
<colgroup span="3">
<col style="width:161px;">
<col style="width: 210px;">
<col style="width: 310px;">
</colgroup>
<tbody>
<tr>
<th style="padding:0px;padding-left:11px;width:150px;"></th>
<th style="padding: 0px 0px 0px 11px; width: 199px;"></th>
<th style="padding: 0px 0px 0px 11px; width: 299px;"></th>
</tr>
<tr>
<th id="someid">
<div style="some style">
<table id="some id">
<tbody>
<tr>
<td _afrsortasc="1"><a tabindex="-1" class="x1nw" title="Sort Ascending"></a></td>
<td _afrsortdesc="1"><a tabindex="-1" class="x1nx" title="Sort Descending"></a></td>
</tr>
</tbody>
</table>
</div>
<div class="x1zr"><span class="af_column_label-text">Name</span></div>
</th>
<th id="someid">
<div style="some style">
<table id="some id">
<tbody>
<tr>
<td _afrsortasc="1"><a tabindex="-1" class="x1nw" title="Sort Ascending"></a></td>
<td _afrsortdesc="1"><a tabindex="-1" class="x1nx" title="Sort Descending"></a></td>
</tr>
</tbody>
</table>
</div>
<div class="x1zr"><span class="af_column_label-text">E-Mail</span></div>
</th>
<th id="someid">
<div style="some style">
<table id="some id">
<tbody>
<tr>
<td _afrsortasc="1"><a tabindex="-1" class="x1nw" title="Sort Ascending"></a></td>
<td _afrsortdesc="1"><a tabindex="-1" class="x1nx" title="Sort Descending"></a></td>
</tr>
</tbody>
</table>
</div>
<div class="x1zr"><span class="af_column_label-text">Manager</span></div>
</th>
</tr>
</tbody>
</table>
</div>
<div id="some id">
<table summary="some summary" class="x1nj x1o7">
<colgroup span="3">
<col style="width:161px;">
<col style="width: 210px;">
<col style="width: 310px;">
</colgroup>
<tbody>
<tr _afrrk="0" class="xep">
<td style="width: 199px;" class="xeq" nowrap=""><a id="someid1" class="someclass1" href="mailto:[email protected]">[email protected]</a></td>
<td style="width: 299px;" class="xeq" nowrap=""><a id="someid2" class="someclass2" onclick="this.focus();return false;" href="#">Name1</a></td>
<td style="width:90px;" class="xeq" nowrap="" align="center"><img id="someimgid1" title="Primary" alt="Primary" class="xje"></td>
</tr>
<tr _afrrk="1" class="xep">
<td class="xeq" nowrap=""><a id="someid3" class="someclass3" href="mailto:[email protected]">[email protected]</a></td>
<td class="xeq" nowrap=""><a id="someid4" class="someclass4" onclick="this.focus();return false;" href="#">Name2</a></td>
<td class="xeq" nowrap="" align="center"><a id="someaid2" title="Primary" class="xko p_AFIconOnly" onclick="this.focus();return false;" href="#"><img id="someimgid2" title="Primary" alt="Primary" class="_afrImageNotLoadedInTime xi8"></a></td>
</tr>
<tr _afrrk="2" class="xep">
<td class="xeq" nowrap=""><a id="someid3" class="someclass3" href="mailto:[email protected]">[email protected]</a></td>
<td class="xeq" nowrap=""><a id="someid4" class="someclass4" onclick="this.focus();return false;" href="#">Name3</a></td>
<td class="xeq" nowrap="" align="center"><a id="someaid3" title="Primary" class="xko p_AFIconOnly" onclick="this.focus();return false;" href="#"><img id="someimgid3" title="Primary" alt="Primary" class="xi8"></a></td>
</tr>
</tbody>
</table>
</div>
<div id="someid123" style="height: 0px; width: 1040px;"></div>
<div id="someid234" class="x1ob" style="position:absolute;display:none"></div>
<div id="someid345" class="x1nk" style="position:absolute;display:none;overflow:hidden"></div>
<div id="someid456" style="display:none"></div>
<div tabindex="-1" id="someid567" style="position: absolute; overflow: auto; z-index: 0; width: 1040px; top: 33px; height: 261px; right: 0px;">
<div style="width: 1040px; height: 223px; visibility: hidden;"></div>
</div>
