首页 > 解决方案 > 使用 Cypress-promise 对我来说,异步等待在循环内部不起作用

问题描述

我收到错误您的回调函数返回了一个从未解决的承诺,我的代码和我是 cypress 3.4.1 版本

```cy.xpath(LOGO).then(async $ele => {
      for (const i in $ele) {
        if ($ele.eq(i).text() === 'USA') {
          $ele.eq(i).click();
          cy.wait(5000);
        }
        const count = await cy.get(COUNT).invoke('text').promisify();
        if(count>0) break;
      }`enter code here`
});```

标签: cypress

解决方案


推荐阅读