我的测试用例在 Cypress 中通过后出错

问题描述

在我的测试用例通过后,我注意到 cypress 试图在我的测试用例结束时运行我的自定义命令,这引发了 AssertionError。

查看代码错误提示

 })

      it('Does not do much!',function() {  
        const productPage = new ProductPage();

        cy.get(':nth-child(2) > .nav-link').click()
          this.key.ProductName.forEach(function(element) {
    
          cy.selectProduct(element)
          productPage.getCheckoutBox().click()
          productPage.getFinalCheckoutBox().click()
          productPage.getAutoCountryBox().type('United States')
          cy.wait(6000)
          productPage.getCountryBox().click() 
          cy.wait(9000)
          productPage.getTermsandConditions().click()  
          productPage.getPurchaseBox().click()
          //productPage.getAlert().should('have.text','Success! Thank you! Your order will be delivered in next few weeks :-).')
          productPage.getAlert().then(function(element2)
          {

            const actualText=element2.text()
              expect(actualText.includes("Success! Thank you! Your order will be delivered in next few weeks")).to.be.true 
            
          })
          })     
           
    })
})

enter image description here

故障排除步骤: 我尝试创建另一个元素,因为我之前创建了一个自定义命令元素。

@Nanker Phelge 请提供任何见解

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)