---
id: api/commands/focused
title: focused | Cypress Documentation
description: Get the DOM element that is currently focused in Cypress.
section: api
source_path: docs/api/commands/focused.mdx
version: 204dffbf7fbb64b1fe8343a54ddcd869cc275f1f
updated_at: '2026-05-12T20:33:17.938Z'
---
# focused

Get the DOM element that is currently focused.

## Syntax

```
cy.focused()cy.focused(options)
```

### Usage

**Correct Usage**

```
cy.focused() // Yields the element currently in focus
```

### Arguments

**options _(Object)_**

Pass in an options object to change the default behavior of `cy.focused()`.

| Option | Default | Description |
| --- | --- | --- |
| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |
| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.focused()` to resolve before [timing out](#Timeouts) |

### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)

*   `cy.focused()` yields the DOM element it found.
*   `cy.focused()` is a query, and it is _safe_ to chain further commands.

## Examples

### No Args

#### Get the element that is focused

```
cy.focused().then(($el) => {  // do something with $el})
```

#### Blur the element with focus

```
cy.focused().blur()
```

#### Make an assertion on the focused element

```
cy.focused().should('have.attr', 'name', 'username')
```

## Rules

### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)

*   `cy.focused()` requires being chained off a command that yields DOM element(s).

### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)

*   `cy.focused()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until the element(s) [exist in the DOM](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Implicit-Assertions).
*   `cy.focused()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until all chained assertions have passed.

### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)

*   `cy.focused()` can time out waiting for the element(s) to [exist in the DOM](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Implicit-Assertions).
*   `cy.focused()` can time out waiting for assertions you've added to pass.

## Command Log

**_Make an assertion on the focused element_**

```
cy.focused().should('have.attr', 'name').and('eq', 'num')
```

The commands above will display in the Command Log as:

When clicking on the `focused` command within the command log, the console outputs the following:

## See also

*   [`.blur()`](/llm/markdown/api/commands/blur.md)
*   [`.focus()`](/llm/markdown/api/commands/focus.md)
