Click Button If Enabled Using cypress-if And cypress-await Plugins @gleb
Click Button If Enabled Using cypress-if And cypress-await Plugins  @gleb
Uploaded February 2024 | Updated November 2026, 2 days ago
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 github.com/bahmutov/cypress-if and github.com/bahmutov/cypress-await Look for a blog post with code examples for this video by following glebbahmutov.com/blog
Click Button If Enabled Using cypress-if And cypress-await PluginsThe Possess Assertion From cypress-map PluginSimplify Cypress Parallel Workflow With A Reusable cypress-split WorkflowTDD Example: Add data- AttributeWhen It ReloadsCheck Every Box In Cypress Tests Without FlakeSee All Chrome Browser Command Line Flags Cypress Uses To Launch The BrowserAdd Random Todo Examplecypress-magic-backend And Your Test Network InterceptsCypress Grep UI Plugins With Dennis BergevinGitHub Copilot Vs Cursor AI: Change Comments Into Commands ExampleGitHub Copilot Agent Mode
gleb bahmutov |

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

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER