Click Button If Enabled Using cypress-if And cypress-await Plugins

Publié le: 21 février 2024
sur la chaîne: gleb bahmutov
1,344
27

This video shows how to do conditional testing (click a button only if it is enabled) using my plugins cypress-if and cypress-await.
// cypress-if solution
cy.contains('button', 'Click Me')
// tests using Chai assertion "be.enabled"
.if('enabled')
.click()
.should('have.text', 'Clicked')
.else('Nothing to click')
// cypress-await solution
const enabled = cy.contains('button', 'Click Me').invoke('is', ':enabled')
cy.log(`enabled? ${enabled}`)
if (enabled) {
cy.contains('button', 'Click Me').click().should('have.text', 'Clicked')
} else {
cy.log('Nothing to click')
}

Plugins repos are https://github.com/bahmutov/cypress-if and https://github.com/bahmutov/cypress-a... Look for a blog post with code examples for this video by following https://glebbahmutov.com/blog/


Sur cette page du site, vous pouvez voir la vidéo en ligne Click Button If Enabled Using cypress-if And cypress-await Plugins durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur gleb bahmutov 21 février 2024, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 1,344 fois et il a aimé 27 téléspectateurs. Bon visionnage!