thegunner February 2016

identifying that table header values are what they should be

I'm trying to prove that in a table we have the following table labels. Date, amount, comment.

<table class="grid-table-body">
        <th>Amount (£)</th>



I've got as far as proving the table is present!

   var myTable = element(by.css('.grid-table-body'));

How can I loop through each <th> and get the text. If I was just to put them into an array I could prove they are what they should be. i.e.


Would be enough (I think)


alecxe February 2016

First locate the elements, then you can call getText():

var headers = $$(".grid-table-body thead th");
expect(headers.getText()).toEqual(["Date", "Amount (£)", "Description"]);

To check that all of the headers are visible, you can either use:

expect(headers.isDisplayed()).toEqual([true, true, true]);

Or, check if there is no false in the array:


You can also map()/reduce() it to a single boolean value.

Post Status

Asked in February 2016
Viewed 1,720 times
Voted 4
Answered 1 times


Leave an answer