Counting items in a table

I have a page with a table, say:

<table> <tr><td>Element1</td></tr> <tr><td>Element2</td></tr> </table> 

I am trying to test with a cucumber and capybara. How can I get the number of rows of a table in a step definition (is this the only table on the page)?

+4
source share
1 answer

You need to get the number of all tr ​​elements in the table.

 page.all("table tr").count 
+4
source

Source: https://habr.com/ru/post/1402113/


All Articles