Replies: 1 comment
-
|
The Here's what works cross-browser (including Firefox): // Shift+Tab using cy.press() — use the array form for key combos
cy.focused().press("{shift+tab}")If that still gives you issues on your version, the fallback that works reliably in Firefox is to dispatch the keyboard events natively via the DOM: cy.focused().then($el => {
const event = new KeyboardEvent("keydown", {
key: "Tab",
code: "Tab",
shiftKey: true,
bubbles: true,
cancelable: true,
})
$el[0].dispatchEvent(event)
})Another approach — trigger the browser's actual focus management by using The native |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have a scenario where I need to simulate the keyboard event Shift+Tab to move focus to the previous element, which could be either a button or an input field. Currently, we use
realPress(['Shift', 'Tab']), which works perfectly in Chrome. However, it does not work in Firefox, likely because CDP is not supported for Firefox.My requirement is specifically for Firefox.

I am using Cypress version 15.3.0, and according to the documentation, this version supports advanced keyboard interactions. However, when I try to perform Shift+Tab using
cy.press('Tab', { shift: true }), I receive a compiler error.Also, alternatively, I tried to achieve this using
cy.focused().type('{shift}{tab}')], but that did not work either. I received an error stating that {tab} isn't a supported character sequence.Please suggest how to achieve this scenario of pressing multiple events like Shift + Tab with Firefox browser
Beta Was this translation helpful? Give feedback.
All reactions