I want to compare path Alert with ExpectedResult, but now the programer not check script in this part, so I use not.exist to skip case that Path Alert is not found, but in case that path Alert is found, Cypress program still reads . not.exist, and I want it to run through it without getting this error.
Timed out retrying after 4000ms: Expected
if (cy.get('.help-block > ul > li').should('not.exist')) {
cy.get('.help-block > ul > li').should('not.exist').then((Path_Alert) => {
console.log(Path_Alert)
if (Path_Alert == null) {
cy.log(data.rows[i].ExpectedResult)
ErrorSuggestion = cy.log('Not Alert or Alert Not Match').as('ErrorSuggestion')
}
})
cy.get('#swal2-title').should('be.visible').invoke('text').then((text) => {
if (text == 'พบข้อผิดพลาด!' || text == 'การเพิ่มสำเร็จ!') {
cy.log(text).as('Alert_Popup')
if (text == 'พบข้อผิดพลาด!') {
result="Fail"
cy.log(result).as('Result')
cy.get('.swal2-confirm').click()
} else if (text == 'การเพิ่มสำเร็จ!') {
cy.get('.swal2-confirm').click()
}
}
})
} else {
if (cy.get('.help-block > ul > li').should('be.visible')) {
cy.get('.help-block > ul > li').should('be.visible').then((Path_Alert) => {
console.log(Path_Alert)
if (expect(Path_Alert).equal(data.rows[i].ExpectedResult)) {
result="Pass"
cy.log(result).as('Result')
}
})
}
cy.get('#swal2-title').should('be.visible').invoke('text').then((text) => {
if (text == 'พบข้อผิดพลาด!' || text == 'การเพิ่มสำเร็จ!') {
cy.log(text).as('Alert_Popup')
if (text == 'พบข้อผิดพลาด!') {
result="Fail"
cy.log(result).as('Result')
cy.get('.swal2-confirm').click()
} else if (text == 'การเพิ่มสำเร็จ!') {
cy.get('.swal2-confirm').click()
}
}
})
}