cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Tab key events can be dispatched to the AUT

Open cacieprins opened this issue 3 weeks ago • 0 comments

What would you like?

In order to more accurately test keyboard-only accessibility pathways, users would like to dispatch a native "tab" keypress to the AUT.

Acceptance Criteria

  • By invoking the cy.press command, users can dispatch a native "Tab" keydown followed immediately by a "Tab" keyup.
  • This command works in Chrome, Firefox, and Edge.

Implementation Notes

Proposed command signature

type PressCommand<T: keyof Cypress.Keyboard.Keys> = {
  (
    key: Cypress.Keyboard.Keys[T],
    options?: Cypress.Keyboard.KeyPressModifiers &
      Partial<Cypress.Loggable & Cypress.Timeoutable>
  ): void;
}

declare namespace Cypress {
  interface Cypress {
    Keyboard: {
      Keys: {
        TAB: 'tab'
      }
    }
  }
}

Automation

Chrome can dispatch this via CDP; Firefox can dispatch this via BiDi. Firefox BiDi is a prerequisite.

  • [ ] CDP Automation
  • [ ] BiDi Automation
  • [ ] Command implementation in @packages/driver

cacieprins avatar Feb 07 '25 16:02 cacieprins