Skip to content

How to query focused state without changing it #14990

Discussion options

You must be logged in to vote

Hi @diminutivesloop

Under the hood, Cypress uses Chai-jQuery assertions that include match assertion. You can use it to check your element like this

cy.focused().should('match', '.expected-element-selector')

See live example at https://glebbahmutov.com/cypress-examples/6.4.0/commands/misc.html#cy-focused

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@diminutivesloop
Comment options

@bahmutov
Comment options

@diminutivesloop
Comment options

Answer selected by bahmutov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants