I'm currently trying to figure out how to get the count of how many rows are displaying in an HTML Grid on a page.

From researching several stack exchanges some people reference GetXPathCount, but my compiler does not recognize this command nor can I find search results for a name space to make it work.

Preferably I would like to use something using By.Id or By.CssSelector.

Could anyone assist me in a solution?

1 Answer 1


The code that was entered by Brandon Garlock won't work for C# which you included in your tags, here is the C# version to help with the row count:


Also be aware that if you have a grid header row, you will want to filter that out so it doesn't throw off your count.

  • I was skeptical when i saw .size because its used to get height and width dimensions. Thanks will try this. Commented Jun 3, 2015 at 19:30
  • This does work and imo now that i have more experience is the best way to perform said task. Commented Jan 9, 2017 at 13:29
  • 1
    xpath is missing a closing ]: "//table[@id='yourIDhere']//tr" instead of "//table[@id='yourIDhere'//tr"
    – return
    Commented Dec 20, 2018 at 16:48
  • @07FwqiRQT you are quite right, that change is reflected
    – DEnumber50
    Commented Jan 21, 2019 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.