赛普拉斯:如何验证表中的2行具有相同的值/ID
嗨,我有一个表,其中有2行具有相同的值,我需要迭代,并且检查2行具有ID:POL-330等,该值作为参数传递。使用Cypress TypeScript请
我已经尝试过
```getNumberOfDocuments(document: string) {
cy.contains('tr > td:nth-child(1)', document).should('have.length.greaterThan', 1);
}```
,也
```getNumberOfDocuments(document: string) {
cy.contains('tr > td:nth-child(1)', document).each(($ele, index, list) => {
cy.wrap($ele).should('have.length.greaterThan', 1)
})
}```
请帮助
Hi I have a table below where 2 rows have same value i need to iterate and check 2 rows have ID: POL-330 etc which is passed as parameter. using cypress typescript please
i have tried
```getNumberOfDocuments(document: string) {
cy.contains('tr > td:nth-child(1)', document).should('have.length.greaterThan', 1);
}```
and also
```getNumberOfDocuments(document: string) {
cy.contains('tr > td:nth-child(1)', document).each(($ele, index, list) => {
cy.wrap($ele).should('have.length.greaterThan', 1)
})
}```
please help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.contains()
命令仅返回第一个匹配元素,因此您无法使用它检查两个行。但是您可以在选择器内部使用
:contains()
(如果要循环),这就是它可能工作的方式
The
.contains()
command only ever returns the first matching element, so you can't use it to check for two rows.But you can use
:contains()
inside the selectorIf you want to loop, this is how it might work