Reputation: 2445
I am trying to test an ag-grid in my Protractor tests.
I'm currently able to loop through each row to verify all columns within the rows below:
for (i = 0; i < 10; i++) {
element.all(by.css(`div[row-id="${i}"] div`))
.map(function (cell) {
return cell.getText();
})
.then(function (cellValues) {
expect(cellValues).toEqual(["Toyota", "Celica", "35000"]);
});
}
But instead of verifying each column, I only want to verify the 1st column in each row.
Can someone please tell me what changes I need to make to my code so that I can do this?
Upvotes: 0
Views: 1092
Reputation: 2858
This is easier than you think. Just get all cells from each row, then return just the first one, getText() on that cell, and assert.
for (i = 0; i < 10; i++) {
element.all(by.css(`div[row-id="${i}"] div`))
.first()
.getText()
.then(cellText => {
expect(cellText).toEqual('Something');
});
}
Upvotes: 1