Ath*_*waj 8 webautomation cypress
Mud*_*era 20
您可以用.find它来解决这两种情况。
要获取表行数:
cy.get("#tableID")
.find("tr")
.then((row) => {
//row.length will give you the row count
cy.log(row.length);
});
Run Code Online (Sandbox Code Playgroud)
要获取特定行的值(索引),您可以执行以下操作。
cy.get("#Table Id")
.find("tr")
.then((rows) => {
rows.toArray().forEach((element) => {
if (element.innerHTML.includes("Your Value")) {
//rows.index(element) will give you the row index
cy.log(rows.index(element));
}
});
});
Run Code Online (Sandbox Code Playgroud)
附加提示:如果您想选择包含值的特定表格单元格,可以执行以下操作:
cy.get("#customers").find("tr").find("td").contains("Germany");
Run Code Online (Sandbox Code Playgroud)
注意:要获取表行索引,可以有许多其他替代方法。希望您能在旅途中弄清楚它们。
| 归档时间: |
|
| 查看次数: |
16342 次 |
| 最近记录: |