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:
driver.FindElements(By.XPath("//table[@id='yourIDhere']//tr")).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.GuardTheGates– GuardTheGates2015年06月03日 19:30:09 +00:00Commented 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.GuardTheGates– GuardTheGates2017年01月09日 13:29:42 +00:00Commented Jan 9, 2017 at 13:29
-
1xpath is missing a closing ]: "//table[@id='yourIDhere']//tr" instead of "//table[@id='yourIDhere'//tr"return– return2018年12月20日 16:48:01 +00:00Commented Dec 20, 2018 at 16:48
-
@07FwqiRQT you are quite right, that change is reflectedDEnumber50– DEnumber502019年01月21日 17:17:24 +00:00Commented Jan 21, 2019 at 17:17
Explore related questions
See similar questions with these tags.