Skip to content
masterclass Buddy

Cypress · Method

cy.focus

Focus one DOM element or the window in a Cypress test. The subject must contain one focusable element, and Cypress yields that same subject.

Last updated

Syntax

.focus()
.focus(options)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • .blur()
  • .click()
  • cy.focused()
  • cy.press()
  • .type()

Source: cy.focus() | Cypress API Documentation. Checked 2026-11-03.