Reputation: 127
I need to check whether the radio button is clickable or not. In some scenarios this radio button is clickable but in some scenarios, the user is not able to click the radio button.
The cursor is not allowed in the not clickable scenario.
Can someone help me for this?
I have attached screenshots below.
I have tried many this but not worked.
checkSkipBtnClickable(){
const checkSkipButton = cy.get(':nth-child(3) > .ant-radio-wrapper')
}
Cursor is not allowed to click
Upvotes: 2
Views: 599
Reputation: 127
This is the answer I got:
cy.contains('h3', 'Skip')
.parent()
.then($el => $el.css('cursor') === 'not-allowed')
.as('checkSkipButton')
cy.get('@checkSkipButton').then(checkSkipButton => {
if (checkSkipButton) {
cy.log("Skip is not available")
}
else{
cy.log("Skip is available")
}
})
Upvotes: 0
Reputation: 32052
This gives you a true/false value in an alias called checkSkipButton
cy.contains('h3', 'Skip')
.parent()
.then($el => $el.css('cursor') === 'not-allowed')
.as('checkSkipButton')
cy.get('@checkSkipButton').then(checkSkipButton => {
if (checkSkipButton) {
...
}
})
Upvotes: 4