Reputation: 2445
I am trying to write a Protractor test that checks the number inside the <strong>
tag below:
I managed to get it working for 1 <tr>
using nth-child
below:
element(by.css('td:nth-child(4)')).getText().then((text) => {
console.log('Text', text);
});
But if I have multiple rows within the table, it only prints the 1st row.
Can someone please tell me what changes I need to make so that I look through each row within the table & print the 4th child?
Upvotes: 0
Views: 270
Reputation: 13712
Use element.all()
element.all(by.css('tr > td:nth-child(4)')).getText().then((texts) => {
// texts is a string array, includes the 4th column values
console.log('Text', texts);
});
// or use element.all().each()
element.all(by.css('tr > td:nth-child(4)')).each((it)=>{
it.getText().then((text)=>{
console.log('Text', texts);
})
});
Upvotes: 1