cy.focused() inconsistent behavior
See original GitHub issue- Operating System: Mac OS X Sierra
- Cypress Version: 1.0.2
- Browser Version: All
Is this a Feature or Bug?
Bug
Current behavior:
cy.focused() does the right thing when you keep the Cypress UI window focused. It does the wrong thing if you blur the Cypress UI window or if you run headlessly.
Desired behavior:
cy.focused() should produce consistent results, regardless of being run headed/headless or focused/blurred.
How to reproduce:
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:17 (12 by maintainers)
Top Results From Across the Web
focused - Cypress Documentation
cy.focused() yields the DOM element it found. cy.focused() is a query, and it is safe to chain further commands.
Read more >Cypress does not always executes click on element
click() on it 2 or more times, I ensured it was first set in focus prior to being clicked. This fixed it for...
Read more >cypress fix this problem, or use {force: true} to disable error ...
Current behavior: CypressError: Timed out retrying: cy.type() failed because this element: <input id="visiblenumber" focus-if="" type="number" maxlength="4" ...
Read more >Autism Spectrum Disorder - National Institute of Mental Health
Social communication / interaction behaviors may include: Making little or inconsistent eye contact; Appearing not to look at or listen to people who...
Read more >Contextualizing the Impostor “Syndrome” - Frontiers
This focus on the individual level of analysis is most likely the result of ... This may also help explain inconsistencies in the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hey, while this works in headless mode,
focused()still fails when using the ui and not having the cypress window focused. It would be great if it worked even when I’m on another tab or in my IDE, etc.@brian-mann meaning these docs are out of date, and you implement the chai-jquery natively (via the string args in
.should())?I also second the OP – currently
cy.focused()yieldswindowobject (in some(?) cases) ).IMO
cy.focused()should correctly yield focused element.Meanwhile, it can be done like this: