I have to deal with a table like this :
<table id="product">
<tr>
<td data-sortable-id="ax01">Axe</td>
<td>Wood</td>
<td>Red</td>
</tr>
<tr>
<td data-sortable-id="ha01">Hammer</td>
<td>Iron</td>
<td>Black</td>
</tr>
<tr>
<td data-sortable-id="na01">Nail</td>
<td>Metal</td>
<td>Black</td>
</tr>
<tr>
<td colspan="3">3 Products Listed</td>
</tr>
</table>
How can I select all td
elements which have the attribute data-sortable-id
? I can't find anything in Google search about finding elements by attribute (without a value, attribute's own name only).
I've tried something like
x = webdriver.find_elements_by_xpath("//td[@data-sortable-id]")
print(len(x))
but the result is 0.