mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-18 22:28:38 -05:00
1.5 KiB
1.5 KiB
title, comments, description
| title | comments | description |
|---|---|---|
| focused | true |
Get the DOM element that is currently focused.
| Returns | the current DOM element that is focused or null |
| Timeout | cy.focused will retry for the duration of the defaultCommandTimeout |
cy.focused()
Get the focused DOM element.
Options
Pass in an options object to change the default behavior of cy.focused.
cy.focused( options )
| Option | Default | Notes |
|---|---|---|
log |
true |
whether to display command in command log |
Usage
Get the element that is focused.
cy.focused()
Make an assertion on the focused element.
cy.focused().should("have.attr", "name", "username")
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: