Get Element Count for table returns zero

I have a table that has multiple rows and columns. I’m using the Selenium “Get Element Count” to get the number of rows but for this particular table, I’m getting always zero rows. If I use the same code for some other tables, on other sites, I’m getting the correct number of rows.

What is different about this table to receive the wrong number of rows? Any ideas?

Hello Miroslav,

Try putting a Wait statement right before your Get Element Count keyword. However, this table has a thead element whereas the others might not? So I think your XPath locator is wrong? Try it with //tbody.

Good luck!

1 Like

Also, I noticed that you are using the ChroPath plugin which I think has been discontinued? So I am not sure if it is working correctly? There is a new plugin by the same author of the ChroPath plugin…I don’t remember the name.

But the best advise I can give you is to learn how to hand roll your own locators, i.e. learn XPath and CSS so that you can write them from scratch yourself. In the long run that skill will be invaluable.


Hello @hobet,

thank you for the hint, Wait statement solve the issue. It looks like that the table loading takes more time than expected and the desired xpath was not existing at the time Get Element Count statement.

I will also take into account your suggestion on learning XPath and CSS.

Thank you!