--- title: last comments: true description: '' --- Get the last DOM element within a set of DOM elements. | | | |--- | --- | | **Returns** | the new DOM element(s) found by the command. | | **Timeout** | `cy.last` will retry for the duration of the [`defaultCommandTimeout`](https://on.cypress.io/guides/configuration#timeouts) | # [cy.last()](#usage) Reduce the set of matched DOM elements to the final one in the set. # Options Pass in an options object to change the default behavior of `cy.last`. **cy.last( *options* )** Option | Default | Notes --- | --- | --- `log` | `true` | whether to display command in command log `timeout` | [`defaultCommandTimeout`](https://on.cypress.io/guides/configuration#timeouts) | Total time to retry getting the element # Usage ## Get the last list item in a list. ```html ``` ```javascript // returns
  • Knick knack on my door
  • cy.get("ul").last() ``` # Command Log ## Find the last button in the form ```javascript cy.get("form").find("button").last() ``` The commands above will display in the command log as: screen shot 2015-11-29 at 12 33 52 pm When clicking on `last` within the command log, the console outputs the following: screen shot 2015-11-29 at 12 34 07 pm # Related - [first](https://on.cypress.io/api/first)