How to get row count for a table
Posted: Tue Nov 05, 2019 10:41 pm
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 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
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 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