-
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
cy.get('button').type() only works if button has tabindex
specified
#2166
Comments
Hi @kyleoliveiro, |
I know. I'm trying to simulate a keypress on a button with |
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 cy.get('button').trigger('keypress', {
keyCode: 35, // whatever code for the key you wanted to press
which: 35 // whatever which for the key you wanted to press
}) Let me know if this works for you. |
Yes it will work; but are there plans to include a |
@kyleoliveiro have you tried |
I tried |
@jennifer-shehane I am still not able to click the button on my page using the above. If there is any work around. What if we can introduce the attribute while it is running and then we try to simulate the key press event??? I am not able to click on the button no matter what I try :( |
@mendax02 if you're trying to click a button, you should refer to our docs on cy.click |
Re-opened this since we want to allow typing into any element that is focusable. This is fixed in #4870 |
* cleanup type_spec, allow unused-vars for args * fix missing return * rename mouse/keyboard * apply changes on this branch with rename * temp 07/18/19 [skip ci] type_spec minor changes * temp 07/19/19 [skip ci] * temp 07/22/19 [skip ci] * temp 07/22/19 [skip ci] * remove accidental spec, use beforeEach visit in click_spec * add tests for cy.trigger changes * re-run build * extract simulated type from native events * most type_spec passing until tab * add typedefs * temp 08/08/19 [skip ci] * fix type_spec, click_spec * fix console table event table logging * fix spec utils * temp 08/12/19 [skip ci] * large changes to selection.ts, working type_spec, eslint changes * fix elements util, cleanup debugging code * fix linting rules * fix type_spec in electron by using plain Event contructor * fix invalid clicking-into-iframe spec * address review, cleanup * use webpack-preprocessor (required for typescript files) * fix invalid connectors_spec * chore(lint): fix linting, since changed rules * fix not borrowing property getter for maxlength * temp 09/25/19 [skip ci] * add test for clicking checkbox, cleanup click_spec * document mouse click and mouse move algo, adjust mouse move, add test for recursive movement * cleanup / formatting * scope the getCommandLogWithText to the active runnable to prevent leakage * cleanup tests, make values static so tests pass consistently - use attach listener alias APIs - remove magic number constants - fix some incoherent html / script tag stuff * begin implementation for returning fromAutWindow - restore original fromWindow algorithm - begin writing fromAutWindow for calculating red hitbox coordinates which are layered on the AUT * move describe block with the others * refactor actions to DRY up duplicated logic between click/dblclick/rightclick - tighten up the mouse.js method names, name them consistently * remove comment * fix iframe coords and test * temp 10/06/19 [skip ci] * rename fromDocCoords->fromWindowCoords, fix type_spec ux test * fix after merge from mouse-fixes branch / develop * temp 10/08/19 [skip ci] * Revert "temp 10/08/19 [skip ci]" This reverts commit 92b73f6. * remove only, fix contenteditable test * add test for datetime-local inputs * add webpack devdep * fix debugging code * fix force:true on hidden input * up timeout for test in ci * tighten up method, remove unnecessary arg * add debug logic for retries to console.error() non cypress errors * renamed fromWindow -> fromElWindow, and fromViewport -> fromElViewport * handle calculating the fromElWindow coordinates inline * extract out function for clarity, receive consistent arg names * cleanup, add lots of comments * fix display specific test * fix type follow focus when redirect on focus * cleanup new follow focus test * upgrade eslint-plugin-dev to 5.0.0 * more [lint fixes] * use typescript in driver * cleanup minor * remove unneeded file * mild refactor webpack configs * fix elements.ts * fix isTextLike signature change * fix isType check, fix type_spec * actually use webpack-preprocessor * fix isType domUtil * fix connectors_spec * cleanup connectors_spec * address feedback- cleanup, add comments, refac * answer: no, need index.js * cleanup after driver typescript PR * fix keyboard getActiveModifiers * fix(driver:keyboard): fix typing negative numbers with existing text selection * remove debugging code, cleanup * link fixed issues in tests, actually fix one issue * cleanup remove dead code * remove unused helper * add test for #2166 * pay no attention to the code and implementation changing... add tests and note for changing focus into date input * mark fix for issue #3316 * mark fix for issue #3722 * rename elements.isType -> elements.isInputType for clarity * restructure keyboard a bit, don't export default, rework static class properties to regular exports - attach $Mouse + $Keyboard to Cypress * tighten up * coffeescript fixes, consistent regexp const naming * capitalize interface, tighten up several modifier functions * misc cleanup and tightening up * rework impl to use stubs instead of numbers * some more cleanup * fix logic with when function is called Co-authored-by: Brian Mann <brian.mann86@gmail.com> Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
The code for this is done in cypress-io/cypress#4870, but has yet to be released. |
Released in |
Current behavior:
When calling
cy.type()
on a<button>
element, Cypress throws:However if the
<button>
has atabindex
attribute of any value specified, then callingcy.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
The text was updated successfully, but these errors were encountered: