Page 1 of 1

How to get row count for a table

Posted: Tue Nov 05, 2019 10:41 pm
by qa-auto
All,

There are so many posts on this issue. Even still, it took me awhile this afternoon to get the row count on my table. Sharing this forward in case it can be a quick solution for someone else.

Table structure
Annotation 2019-11-05 153024.jpg
Repository element RxPath
div/table[@id='ctl00_MainContent_CustSrch_gvCustomerList']/tbody

TableUserCodeCollection
[UserCodeMethod]
public static int TableRowCount(Adapter element)
{
TBodyTag tbody = new TBodyTag(element);
int rowCount = tbody.Children.Count;
Report.Info("User", "Table size: " + (rowCount - 1).ToString());
// header is first row so subtract 1
return (rowCount - 1);
}

The KEY thing is to add '/tbody' to your RxPath.

Hope this is helpful!
Lorinda