I'm trying to retrieve all elements from a html table td, however when I try to find elements by xpath with multiple conditions it fails retrieving 0 elements, there is no problem getting all values with a single condition. So far my issue is probably in the order of the html elements.
This is the search by a single condition using xpath which works fine:
"//input[@class='managebtn'][@value='repost']"
This is what I am trying to achieve without desired result:
"//td[contains(text(),'manage')]/div[@class='regular']/form[@class='manage']/input[@class='managebtn'][@value='repost']"
The following html table is the one I am trying to read"
<tbody aria-live="polite" aria-relevant="all">
<tr class="posting-row odd ui-state-default" role="row">
<td class="status expired">
<small class="gc" style="background:">
Expired </small>
</td>
<td class="buttons expired"></td>
</tr>
<tr class="posting-row even ui-widget-content" role="row">
<td class="status deleted">
<small class="gc" style="background:">
Deleted </small>
</td>
<td class="buttons deleted">
<div class="regular">
<form action="https://" method="GET" class="manage display">
<input type="hidden" name="action" value="display">
<input type="submit" name="go" value="display" class="managebtn">
</form>
<form action="https://" method="GET" class="manage ">
<input type="hidden" name="action" value="repost">
<input type="submit" name="go" value="repost" class="managebtn">
</form>
</div>
</td>
</tr>
<tr class="posting-row odd ui-state-default" role="row">
<td class="status deleted">
<small class="gc" style="background:">
Deleted </small>
</td>
<td class="buttons deleted">
<div class="regular">
<form action="https://" method="GET" class="manage display">
<input type="hidden" name="action" value="display">
<input type="submit" name="go" value="display" class="managebtn">
</form>
<form action="https://" method="GET" class="manage ">
<input type="hidden" name="action" value="repost">
<input type="submit" name="go" value="repost" class="managebtn">
</form>
</div>
</td>
</tr>
<tr class="posting-row even ui-widget-content" role="row">
<td class="status deleted">
<small class="gc" style="background:">
Deleted </small>
</td>
<td class="buttons deleted">
<div class="regular">
<form action="https://" method="GET" class="manage display">
<input type="hidden" name="action" value="display">
<input type="submit" name="go" value="display" class="managebtn">
</form>
<form action="https://" method="GET" class="manage ">
<input type="hidden" name="action" value="repost">
<input type="submit" name="go" value="repost" class="managebtn">
</form>
</div>
</td>
</tr>
I only want to retrieve all values from second column (value='repost')only when the first column has the value Expired.
Looks like since this table has multiple elements inside the columns, maybe there something I am overlooking.
Since the columns have th like this:
<th data-column="0" class="tablesorter-header tablesorter-headerUnSorted ui-widget-header ui-corner-all ui-state-default" tabindex="0" scope="col" role="columnheader" aria-disabled="false" unselectable="on" style="user-select: none;" aria-sort="none" aria-label="status: No sort applied, activate to apply an ascending sort">
<div class="tablesorter-wrapper" style="position:relative;height:100%;width:100%">
<div class="tablesorter-header-inner">
status <i class="tablesorter-icon ui-icon ui-icon-carat-2-n-s"></i>
</div>
</div>
</th>
<th class="sorter-false tablesorter-header tablesorter-headerUnSorted ui-widget-header ui-corner-all ui-state-default" data-column="1" scope="col" role="columnheader" aria-disabled="true" unselectable="on" style="user-select: none;" aria-sort="none" aria-label="manage: No sort applied, sorting is disabled">
<div class="tablesorter-wrapper" style="position:relative;height:100%;width:100%">
<div class="tablesorter-header-inner">
manage <i class="tablesorter-icon ui-icon"></i>
</div>
</div>
</th>
I do't know if it is possible to have a line of code like this one in order to get the values I need:
driver.findElement(By.xpath("//th[@class='sorter-false tablesorter-header tablesorter-headerUnSorted ui-widget-header ui-corner-all ui-state-default' and @text()='manage']"));
This is how the table looks like: