【问题标题】:How to turn off AssertionError in cypress when I use if elseHow to turn off AssertionError in cypress when I use if else
【发布时间】:2022-12-02 03:51:29
【问题描述】:

I have a problem with if in cypress test, when the element is not visible I receive: "AssertionError: Timed out retrying after 4000ms: Expected to find element: [type="alertdialog"], but never found it." but I would like to receive cy.log("test") when the element is not visible. There is any possibility to do that?

            if ($dis.is(':visible')) {
                cy.get('[button="reject"]').click()
            } else {
                cy.log("test")
            }
        })```

【问题讨论】:

    标签: cypress


    【解决方案1】:

    Try with this. Example based on Cypress docs...

    cy.get('body').then($body => {
        const dis = $body.find('.some_class')
        if (dis.length) {
            cy.get('[button="reject"]').click()
        } else {
            cy.log("test")
        }
    })
    

    【讨论】:

      猜你喜欢
      • 2022-12-27
      • 2022-12-27
      • 2023-02-22
      • 2022-12-27
      • 2022-12-27
      • 2022-12-16
      • 2022-12-02
      • 2022-12-27
      • 2022-12-27
      相关资源
      最近更新 更多