user3909296 user3909296 - 3 months ago 23
TypeScript Question

How can I get the number of children from an element with protractor?

I am using Protractor and I want to know the number of children from an element.

The element I have is a table element.

let table = element(by.css('#myTable'));

Now I want to assert the number of table entries. How can that be done, based on the table element I have?


Try to get all child tr tags from the table and use count() method to get the number of rows present.

let table = element(by.css('#myTable'));
let rowCount = table.all(by.css("tr")).count()