how to count number of td/tr in a table with Robot Framework using Selenium2Library
robotframework, selenium, xpath
Solution
You can use this XPath to get `<td>` having `style` attribute value contains `width` :
.//table[@id='myTable']/tr/td[contains(@style, 'width')]
Problem
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