小智 9
要获取元素的计数,您可以使用下面的代码。
let countOfElements = 0;
cy.get(".element-selector").then($elements => {
countOfElements = $elements.length;
});
Run Code Online (Sandbox Code Playgroud)
如果你想验证元素的数量,你可以像下面这样做。
// retry until we find 5 matching <.element-selector>
cy.get('.element-selector').should('have.length', 5)
Run Code Online (Sandbox Code Playgroud)
您可以在Cypress Docs中查看更多相关信息。
| 归档时间: |
|
| 查看次数: |
17521 次 |
| 最近记录: |