Files
cypress/docs/source/api/commands/find.md
T

1.7 KiB

title, comments, description
title comments description
find true

Get the descendents DOM elements of a specific selector.

Returns the new DOM element(s) found by the command.
Timeout cy.find will retry for the duration of the defaultCommandTimeout

cy.find( selector )

Get the descendants of each DOM element in the current set of matched DOM elements within the selector.

Options

Pass in an options object to change the default behavior of cy.find.

cy.find( selector, options )

Option Default Notes
log true whether to display command in command log
timeout defaultCommandTimeout Total time to retry getting the element

Selector Usage

Get li's within parent

<ul id="parent">
  <li class="first"></li>
  <li class="second"></li>
</ul>
// returns [<li class="first"></li>, <li class="second"></li>]
cy.get('#parent').find('li')

Command Log

Find the li's within the nav

cy.get('.left-nav>.nav').find('>li')

The commands above will display in the command log as:

screen shot 2015-11-27 at 2 19 38 pm

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

screen shot 2015-11-27 at 2 19 54 pm

Related