提问人:automation-ninja 提问时间:11/13/2023 更新时间:11/13/2023 访问量:23
无法对在赛普拉斯中找到或未找到的元素执行正确的流程
Cannot perform right flow for element found or not found in Cypress
问:
我在使用 Cypress 自定义命令时遇到了问题。该命令旨在根据某些元素的结果检查某些元素的可见性。下面是相关的代码片段:
Cypress.Commands.add('checkEstablishments', () => {
accessManagement.getEstablishmentResult().then(($result) => {
if ($result.length >= 1) {
accessManagement.getEstablishments()
.should('be.visible', { timeout: 15000 });
} else {
accessManagement.getEstablishmentNotFoundMsg()
.should('exist')
.should('be.visible')
.and('contain.text', 'No establishment found');
}
});
});
运行此命令时,我在 Cypress 控制台中遇到以下错误:
if ($result.length >= 1) {
accessManagement.getEstablishments()
.should('be.visible');
^
} else {
accessManagement.getEstablishmentNotFoundMsg()
.should('exist')
在 accessManagement.getEstablishments() 调用后使用 .should('be.visible') 似乎存在问题。我不确定为什么会这样。有人可以帮我理解和解决这个问题吗?
答: 暂无答案
评论
accessManagement.getEstablishments()