如何在不使用 XPath 的情况下读取量角器中 table 中的特定行?

How to read a specific row in a table in Protractor without using XPath?

我正在尝试编写一个 Protractor 测试来检查下面 <strong> 标签内的数字:

我使用下面的 nth-child 设法让它工作了 1 <tr>

element(by.css('td:nth-child(4)')).getText().then((text) => {
    console.log('Text', text);
});

但是如果我在 table 中有多行,它只打印第一行。

有人可以告诉我需要进行哪些更改,以便我查看 table 中的每一行并打印第 4 个 child 吗?

使用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);
  })
});