柏树测试正在计时
我需要验证页面上搜索的元素之一。
如果其中一个出现,则期望陈述应评估为true。
我已经按下F12,并验证了“下载ReferencesRow”以及其他元素之一。但是,柏树的时间就会出现。
我的代码看起来还可以吗?
var numberOfElements = 0;
cy.get('downloadReferencesRow').then((body) =>{
if (body.find('createApplicationReferencesPresent').length > 0) {
numberOfElements +=1;
}
if (body.find('createApplicationNoReferencesPresent').length > 0) {
numberOfElements +=1;
}
});
expect(numberOfElements).eq(1);
I need to validate that one of the elements I am searching for appears on the page.
if one of them appears the expect statement should evaluate to true.
I have pressed f12 and validated that the 'downloadReferencesRow' along with one of the other elements is appearing. but cypress it timing out.
Does my code look ok?
var numberOfElements = 0;
cy.get('downloadReferencesRow').then((body) =>{
if (body.find('createApplicationReferencesPresent').length > 0) {
numberOfElements +=1;
}
if (body.find('createApplicationNoReferencesPresent').length > 0) {
numberOfElements +=1;
}
});
expect(numberOfElements).eq(1);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该代码具有混合同步和异步命令,这是有问题的。
您可以使用jQuery多个选择器(例如所有有条件测试)更轻松地进行操作
,仅当页面稳定时才有效。
The code has mixed synchronous and asynchronous commands, which is problematic.
You can more easily do it with jQuery multiple selectors
Like all conditional testing, it only works if the page is stable.