{
  "doc": {
    "id": "api/commands/focused",
    "title": "cy.focused()",
    "description": "Get the DOM element that is currently focused in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/focused.md",
    "version": "c4ad6f88c531de58221c73dd91a75af7138334b8",
    "updated_at": "2026-11-10T01:15:02.829Z",
    "headings": [
      {
        "id": "api/commands/focused#focused",
        "text": "focused",
        "level": 1
      },
      {
        "id": "api/commands/focused#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/focused#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/focused#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/focused#yields",
        "text": "Yields",
        "level": 3
      },
      {
        "id": "api/commands/focused#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/focused#no-args",
        "text": "No Args",
        "level": 3
      },
      {
        "id": "api/commands/focused#get-the-element-that-is-focused",
        "text": "Get the element that is focused",
        "level": 4
      },
      {
        "id": "api/commands/focused#blur-the-element-with-focus",
        "text": "Blur the element with focus",
        "level": 4
      },
      {
        "id": "api/commands/focused#make-an-assertion-on-the-focused-element",
        "text": "Make an assertion on the focused element",
        "level": 4
      },
      {
        "id": "api/commands/focused#assert-that-no-element-has-focus",
        "text": "Assert that no element has focus",
        "level": 4
      },
      {
        "id": "api/commands/focused#check-which-element-has-focus-on-page-load",
        "text": "Check which element has focus on page load",
        "level": 4
      },
      {
        "id": "api/commands/focused#act-on-the-element-that-has-focus",
        "text": "Act on the element that has focus",
        "level": 4
      },
      {
        "id": "api/commands/focused#keyboard-and-focus-management",
        "text": "Keyboard and focus management",
        "level": 3
      },
      {
        "id": "api/commands/focused#move-focus-with-the-tab-key",
        "text": "Move focus with the Tab key",
        "level": 4
      },
      {
        "id": "api/commands/focused#move-focus-with-the-arrow-keys",
        "text": "Move focus with the arrow keys",
        "level": 4
      },
      {
        "id": "api/commands/focused#check-that-a-skip-link-receives-focus-first",
        "text": "Check that a skip link receives focus first",
        "level": 4
      },
      {
        "id": "api/commands/focused#return-focus-to-the-trigger-when-a-dialog-closes",
        "text": "Return focus to the trigger when a dialog closes",
        "level": 4
      },
      {
        "id": "api/commands/focused#keep-focus-inside-a-dialog",
        "text": "Keep focus inside a dialog",
        "level": 4
      },
      {
        "id": "api/commands/focused#move-focus-to-the-first-invalid-field",
        "text": "Move focus to the first invalid field",
        "level": 4
      },
      {
        "id": "api/commands/focused#options",
        "text": "Options",
        "level": 3
      },
      {
        "id": "api/commands/focused#wait-for-focus-that-moves-after-a-delay",
        "text": "Wait for focus that moves after a delay",
        "level": 4
      },
      {
        "id": "api/commands/focused#shadow-dom-and-iframes",
        "text": "Shadow DOM and iframes",
        "level": 3
      },
      {
        "id": "api/commands/focused#get-a-focused-element-inside-a-shadow-dom",
        "text": "Get a focused element inside a shadow DOM",
        "level": 4
      },
      {
        "id": "api/commands/focused#get-the-iframe-that-holds-focus",
        "text": "Get the iframe that holds focus",
        "level": 4
      },
      {
        "id": "api/commands/focused#notes",
        "text": "Notes",
        "level": 2
      },
      {
        "id": "api/commands/focused#nothing-focused",
        "text": "Nothing focused",
        "level": 3
      },
      {
        "id": "api/commands/focused#shadow-dom",
        "text": "Shadow DOM",
        "level": 3
      },
      {
        "id": "api/commands/focused#iframes",
        "text": "Iframes",
        "level": 3
      },
      {
        "id": "api/commands/focused#scope-of-cy-focused",
        "text": "Scope of cy.focused()",
        "level": 3
      },
      {
        "id": "api/commands/focused#assert-focus-on-a-known-element",
        "text": "Assert focus on a known element",
        "level": 3
      },
      {
        "id": "api/commands/focused#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/focused#requirements",
        "text": "Requirements",
        "level": 3
      },
      {
        "id": "api/commands/focused#assertions",
        "text": "Assertions",
        "level": 3
      },
      {
        "id": "api/commands/focused#timeouts",
        "text": "Timeouts",
        "level": 3
      },
      {
        "id": "api/commands/focused#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/focused#history",
        "text": "History",
        "level": 2
      },
      {
        "id": "api/commands/focused#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "content": {
    "type": "root",
    "children": [
      {
        "type": "heading",
        "depth": 1,
        "children": [
          {
            "type": "text",
            "value": "focused"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Get the DOM element that is currently focused."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Syntax"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.focused()\ncy.focused(options)"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Usage"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Correct Usage"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.focused() // Yields the element currently in focus"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Arguments"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "options (Object)"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Pass in an options object to change the default behavior of `cy.focused()`."
          }
        ]
      },
      {
        "type": "table",
        "align": [
          null,
          null,
          null
        ],
        "children": [
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Option"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Default"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Description"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`log`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`true`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Displays the command in the "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/core-concepts/open-mode.md#Command-Log",
                    "children": [
                      {
                        "type": "text",
                        "value": "Command log"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`timeout`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/configuration.md#Timeouts",
                    "children": [
                      {
                        "type": "text",
                        "value": "`defaultCommandTimeout`"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Time to wait for `cy.focused()` to resolve before "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Timeouts",
                    "children": [
                      {
                        "type": "text",
                        "value": "timing out"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Yields"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`cy.focused()` yields the DOM element that currently has focus."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "When no element has focus, `cy.focused()` yields an empty jQuery object. Its implicit assertion then fails unless you assert that the element does "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "#Assert-that-no-element-has-focus",
                    "children": [
                      {
                        "type": "text",
                        "value": "not exist"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": "."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`cy.focused()` is a query, and it is safe to chain further commands."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Examples"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "No Args"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Get the element that is focused"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.focused().then(($el) => {\n  // do something with $el\n})"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Blur the element with focus"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.focused().blur()"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Make an assertion on the focused element"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.focused().should('have.attr', 'name', 'username')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Assert that no element has focus"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.focused().should('not.exist')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Check which element has focus on page load"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.visit('/login')\ncy.focused().should('have.attr', 'name', 'username')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Act on the element that has focus"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "When your app moves focus for you, such as a one-time code input that advances to the next box, chain the next command off `cy.focused()` instead of querying the element yourself."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.get('[data-cy=\"otp-1\"]').type('4')\ncy.focused().should('have.attr', 'data-cy', 'otp-2').type('2')"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Keyboard and focus management"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Move focus with the Tab key"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/press.md",
            "children": [
              {
                "type": "text",
                "value": "`cy.press()`"
              }
            ]
          },
          {
            "type": "text",
            "value": " dispatches real keyboard events, so the browser moves focus the same way it does for a keyboard user."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.get('#first-name').focus()\ncy.press(Cypress.Keyboard.Keys.TAB)\ncy.focused().should('have.attr', 'id', 'last-name')\ncy.press(Cypress.Keyboard.Keys.TAB)\ncy.focused().should('have.attr', 'id', 'email')"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Click a `focused` row in the Command Log to pin its snapshot. Cypress highlights the element that had focus at that step, which shows where each Tab press moved focus:"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Move focus with the arrow keys"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Tabs, menus, and toolbars often move focus with the arrow keys instead of Tab. Assert where focus lands after each key press."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.get('[role=\"tab\"]').first().focus()\ncy.press(Cypress.Keyboard.Keys.RIGHT)\ncy.focused().should('have.attr', 'aria-controls', 'panel-2')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Check that a skip link receives focus first"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.visit('/')\ncy.press(Cypress.Keyboard.Keys.TAB)\ncy.focused().should('contain', 'Skip to main content')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Return focus to the trigger when a dialog closes"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.get('[data-cy=\"open-settings\"]').click()\ncy.press(Cypress.Keyboard.Keys.ESC)\ncy.focused().should('have.attr', 'data-cy', 'open-settings')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Keep focus inside a dialog"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "A modal dialog traps focus, so pressing Tab on its last control wraps back to its first control instead of reaching the page behind it."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.get('[role=\"dialog\"]').find('button').last().focus()\ncy.press(Cypress.Keyboard.Keys.TAB)\ncy.focused().should('have.attr', 'data-cy', 'dialog-first-field')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Move focus to the first invalid field"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "If your app moves focus to the first invalid field when a form fails validation, assert where focus lands after submitting."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.get('form').submit()\ncy.focused().should('have.attr', 'name', 'email')"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Options"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Wait for focus that moves after a delay"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "When focus moves after an animation or a network request, pass a longer `timeout`. It applies to `cy.focused()` and the assertions chained to it."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.get('[data-cy=\"load-more\"]').click()\ncy.focused({ timeout: 10000 }).should('have.attr', 'data-cy', 'first-new-item')"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Shadow DOM and iframes"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Get a focused element inside a shadow DOM"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.get('my-search').shadow().find('input').focus()\ncy.focused().should('have.attr', 'type', 'search')"
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Get the iframe that holds focus"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "When focus is inside an iframe, `cy.focused()` yields the `<iframe>` element."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.get('iframe#card-form').its('0.contentDocument.body').find('input').focus()\ncy.focused().should('match', 'iframe#card-form')"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Notes"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Nothing focused"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "When no element has focus, the browser reports the document's `<body>` as the active element. `cy.focused()` doesn't treat `<body>` as focused, so it yields nothing and retries until an element receives focus or the command times out. To assert that nothing has focus, chain `.should('not.exist')`. The exception is a `<body>` with `contenteditable`, which `cy.focused()` yields."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Shadow DOM"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "When the focused element is inside an open shadow root, `cy.focused()` yields that element rather than its shadow host. This does not require the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/configuration.md#Global",
            "children": [
              {
                "type": "text",
                "value": "`includeShadowDom`"
              }
            ]
          },
          {
            "type": "text",
            "value": " option."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Iframes"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`cy.focused()` reads the `activeElement` of the application's top-level document. It follows shadow roots, but it doesn't look inside iframes, so when focus is inside an iframe it yields the `<iframe>` element. See "
          },
          {
            "type": "link",
            "title": null,
            "url": "#Get-the-iframe-that-holds-focus",
            "children": [
              {
                "type": "text",
                "value": "Get the iframe that holds focus"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Scope of `cy.focused()`"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`cy.focused()` always searches the whole document. It ignores the subject it is chained from and the scope set by "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/within.md",
            "children": [
              {
                "type": "text",
                "value": "`.within()`"
              }
            ]
          },
          {
            "type": "text",
            "value": "."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Assert focus on a known element"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`cy.focused()` answers \"which element has focus?\" When you already know which element should have focus, assert on that element directly with the `focus` "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/assertions.md#Chai-jQuery",
            "children": [
              {
                "type": "text",
                "value": "assertion"
              }
            ]
          },
          {
            "type": "text",
            "value": ":"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.get('#email').should('have.focus')"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Rules"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Requirements"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`cy.focused()` requires being chained off of `cy`."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Assertions"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`cy.focused()` automatically "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/core-concepts/retry-ability.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "retries"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " until the element "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/core-concepts/introduction-to-cypress.md#Implicit-Assertions",
                    "children": [
                      {
                        "type": "text",
                        "value": "exists in the DOM"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": "."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`cy.focused()` automatically "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/core-concepts/retry-ability.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "retries"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " until all chained assertions have passed."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Timeouts"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`cy.focused()` can time out waiting for the element to "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/core-concepts/introduction-to-cypress.md#Implicit-Assertions",
                    "children": [
                      {
                        "type": "text",
                        "value": "exist in the DOM"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": "."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`cy.focused()` can time out waiting for assertions you've added to pass."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Command Log"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Make an assertion on the focused element"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.focused().should('have.attr', 'name').and('eq', 'num')"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "The commands above will display in the Command Log as:"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "When clicking on the `focused` command within the command log, the console outputs the element it yielded (`Yielded`) and how many elements it found (`Elements`):"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "History"
          }
        ]
      },
      {
        "type": "table",
        "align": [
          null,
          null
        ],
        "children": [
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Version"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Changes"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#13-7-1",
                    "children": [
                      {
                        "type": "text",
                        "value": "13.7.1"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Yields the focused element inside a shadow root"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#12-0-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "12.0.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`cy.focused()` became a query"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#0-20-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "0.20.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Retries until the element exists in the DOM"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "See also"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/commands/blur.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "`.blur()`"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/commands/focus.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "`.focus()`"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  },
  "token_estimate": 1212
}