-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for "focus" assertion (to work effectively as Chai jQuery assertion does) #97
Comments
Hi, I need a test for checking focus too and I think this could be a nice workaround? Instead of checking if the element you select is focussed, you get the focussed element and check if the properties/attributes or whatever are conform expectations. In my case, I needed a focus on the field with a name cy.focused().should('have.attr', 'name', fieldName); |
Hi, after this PR #3219 , you will be able to do the following assertions: cy.get('div').should('have.focus')
cy.get('div').should('not.have.focus')
cy.get('div').should('be.focused')
cy.get('div').should('not.be.focused')
expect(div).to.have.focus
expect(div).to.not.have.focus
expect(div).to.be.focused
expect(div).to.not.be.focused |
Fixed by #3219 |
Released in |
I'm getting "CypressError: The chainer: 'focus' was not found. Could not build assertion." with Cypress 3.3.0 when I do |
I second that. Whether I use |
Currently looking into this Edit: looks like it never made it into the develop branch https://github.com/cypress-io/cypress/compare/v3.3.0 We'll have this fixed soon |
The code for this is done in cypress-io/cypress#4274, but has yet to be released. |
Released in |
Would be nice to have another assertion to check if the element is either focus, or contains focused element. |
Chai jQuery added a
focus
assertion recently.Cypress needs support for focus assertions so I can assert whether a DOM element has or does not have focus.
Example
The text was updated successfully, but these errors were encountered: