I am using Robot Framework to automatically check the number of TDs or TRs in a table.
I am using Get Matching XPath Count keyword from Selenium, however, it always fails with an error.
My sample HTML structure:
<table id="myTable">
<tr>
<td style="width: 50%">my td</td>
<td style="width: 50%">my td</td>
</tr>
<tr>
<td style="width: 50%">my td</td>
<td style="width: 50%">my td</td>
</tr>
<tr>
<td style="width: 50%">my td</td>
<td style="width: 50%">my td</td>
</tr>
<tr>
<td>Search me</td>
<td>Pagination here</td>
</tr>
</table>
I am using the keyword with XPath : .//[@id='myTable']/tr/td/@width
Because I just want to count td with a "width" attribute.
and the error: InvalidSelectorException: Message: u"invalid selector: Unable to locate an element with the XPath expression...
Any solution? thanks
You can use this XPath to get <td>
having style
attribute value contains width
:
.//table[@id='myTable']/tr/td[contains(@style, 'width')]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With