Reputation: 111
I'm trying to create selenium xpath for various column links in table. Each row is uniquely identified. In each row I know name of one column(name of product) and based on product name I'm trying to find other links in table to perform other operation on that product, such as change start and end date and remove the product etc.
Can some one shed a light creating xpath for each column in table. Table names appears as follows :
tooltip nameofprodduct percentage startdate enddate checkbox1 checkbox2 remove
<tr id="225259">
<td><a class="tooltip "><img alt="info" src="media/tooltip.gif" class="tooltip"><div style="display: none;"></a></td>
<td>name(299106)</td>
<td><div class="increse"><div style="display: none;" class="slidermetrics"></div><span onclick="showBoostSlider(225259,0,0,0,0);" class="increse">0%</span></td>
<td nowrap="nowrap" class="start"><span class="nonEdit"><span class="pointer">none</span><a href="#" class="ui-corner-all ui-button-small"><span class="icon-date"></span></a></span><span style="display: none;" class="edit"><input type="text" value="" style="width: 80px; margin-right: 7px;" class="inlineCalendarDisplay"><input type="hidden" value="" class="inlineCalendar"><a href="#" class="close"><span class="icon-cancel"></span></a><a href="#" class="save"><span class="icon-disk"></span></a></span><span class="tablesorterHiddenSortData"></span></td>
<td nowrap="nowrap" class="end"><span class="nonEdit"><span class="pointer">none</span><a href="#" class="ui-corner-all ui-button-small"><span class="icon-date"></span></a></span><span style="display: none;" class="edit"><input type="text" value="" style="width: 80px; margin-right: 7px;" class="inlineCalendarDisplay"><input type="hidden" value="" class="inlineCalendar"><a href="#" class="close"><span class="icon-cancel"></span></a><a href="#" class="save"><span class="icon-disk"></span></a></span><span class="tablesorterHiddenSortData"></span></td>
<td><input type="checkbox" onchange="switchEnabled('PEnabled',this,'225259');" checked="checked"></td>
<td><input type="checkbox" onchange="switchEnabled('SEnabled',this,'225259');" checked="checked"></td>
<td><a onclick="$('#tab3 > table.jsonTable').rGrid('remove',225259); return false;" href="#">remove</a></td>
</tr>
Upvotes: 1
Views: 1667
Reputation: 24826
May be you are looking for this XPath which returns all links of all rows of all tables with given name:
"//table/tr/td[.='name(299106)']/..//a"
To access the columns of a specific row, you can use:
"//table/tr[id='225259']/td"
Upvotes: 1