cy.get('button').type() only works if button has `tabindex` specified
See original GitHub issueCurrent behavior:
When calling cy.type()
on a <button>
element, Cypress throws:
CypressError: cy.type() failed because it requires a valid typeable element.
However if the <button>
has a tabindex
attribute of any value specified, then calling cy.type()
will succeed.
Desired behavior:
cy.type()
should succeed in any case, since <buttons>
are naturally focusable.
Steps to reproduce:
Call cy.type()
on <button>
(will throw).
Call cy.type()
on <button tabindex="-1">
(will succeed).
Call cy.type()
on <button tabindex="0">
(will succeed).
Call cy.type()
on <button tabindex="1">
(will succeed).
Versions
Cypress 3.0.2
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
type - Cypress Documentation
Type into a DOM element. It is unsafe to chain further commands that rely on the subject after .type(). Syntax Usage Correct Usage...
Read more >Cypress - Select button that contains text - Stack Overflow
I solved it using cy.contains('button', 'Edit Claim').should('be.disabled');.
Read more >cy.type() failed because it targeted a disabled element
type() failed because it requires a valid typeable element. However if the <button> has a tabindex attribute of any value specified, then calling ......
Read more >Cypress Cheat Sheet - LinkedIn
get is like findElement, identifies the element in the web page based on css ... cy.get('#alert').click() //which opens only ok button alert.
Read more >Working with Dynamic Element Ids, Classes and Attributes
We run cy.get(“#someBox”) to get an element which has an ID of ... .type() or .then(()=>) on the custom command in the test...
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 FreeTop 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
Top GitHub Comments
Hi @kyleoliveiro, the error should have also given you information about what we consider typeable including:
If you want to simulate a specific event on the
button
, I’d suggest usingtrigger
to trigger that event like:Let me know if this works for you.
Re-opened this since we want to allow typing into any element that is focusable. This is fixed in #4870