New to Cypress and JavaScript, Please help
I was automating the test case to check the enabled/disabled state of the button on the condition of a few elements to have 'src' html attribute with a value '/Client/images/iconNo.png' (button will be disabled) and /Client/images/iconYes.png (button will be enabled).
I used if statement to check the above condition by wrapping the objects to get the value and using '.then()' method, below is the javascript code
cy.get('.eligibilitySuccessfulGrant > :nth-child(1) > .cursor')
.then(($checkListIcon) =>{
if(cy.wrap($checkListIcon).should('have.attr', 'src', '/Client/images/iconNo.png')){
verifyQIAPTab.clickRequestOrientation().should('be.disabled')
}
else (cy.wrap($checkListIcon).should('have.attr', 'src', '/Client/images/iconYes.png'))
{
verifyQIAPTab.clickRequestOrientation().should('be.enabled').click()
}
})
Problem: if the first 'if' statement is true then it should pass the test case but the cypress is throwing an error that the else condition is not satisfied.
where the cypress is checking that .should('be.enabled').click()
condition. How can I resolve this?
OR
Is there any other way in cypress to check my above test case?
Please help and suggest Thanks a lot in advance
Aucun commentaire:
Enregistrer un commentaire