user3909296 user3909296 - 1 year ago 85
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?

Answer Source

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()
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download