How to query focused state without changing it #14990
-
I'm trying to create a test for keyboard focus trapping in a modal component and I'm using the cypress-real-events package to simulate tabbing events. However when I try to verify that the expected element is focused after tabbing I run into issues. If I use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
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 |
Beta Was this translation helpful? Give feedback.
Hi @diminutivesloop
Under the hood, Cypress uses Chai-jQuery assertions that include match assertion. You can use it to check your element like this
See live example at https://glebbahmutov.com/cypress-examples/6.4.0/commands/misc.html#cy-focused