Files
cypress/docs/source/api/commands/nextall.md
T
Jennifer Shehane cbec33d637 Converted 'its' - 'pause'
- Updated some existing api docs to reflect structure changes
- Added missing ‘pause’ command to sidebar and .yml english.
2017-05-26 14:31:41 -04:00

2.8 KiB

title, comments, description
title comments description
nextall true

Get all following siblings of each DOM element in a set of matched DOM elements.

Syntax

.nextAll()
.nextAll(selector)
.nextAll(options)
.nextAll(selector, options)

Usage

.nextAll() requires being chained off another cy command that yields a DOM element or set of DOM elements.

{% fa fa-check-circle green %} Valid Usage

cy.get('.active').nextAll() // Yield all links next to `.active`

{% fa fa-exclamation-triangle red %} Invalid Usage

cy.nextAll()                // Errors, cannot be chained off 'cy'
cy.getCookies().nextAll()   // Errors, 'getCookies' does not yield DOM element

Arguments

{% fa fa-angle-right %} selector (String selector)

A selector used to filter matching DOM elements.

{% fa fa-angle-right %} options (Object)

Pass in an options object to change the default behavior of .nextAll().

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

Yields

.nextAll() yields the new DOM elements found by the command.

Timeout

.nextAll() will continue to look for all next element(s) for the duration of the defaultCommandTimeout

Examples

All Next

Find all of the element's siblings following .second

<ul>
  <li>apples</li>
  <li class="second">oranges</li>
  <li>bananas</li>
  <li>pineapples</li>
  <li>grapes</li>
</ul>
// yields [<li>bananas</li>, <li>pineapples</li>, <li>grapes</li>]
cy.get('.second').nextAll()

Selector

Find all of the following siblings of each li. Keep only the ones with a class selected.

<ul>
  <li>apples</li>
  <li>oranges</li>
  <li>bananas</li>
  <li class="selected">pineapples</li>
  <li>grapes</li>
</ul>
// yields <li>pineapples</li>
cy.get('li').nextAll('.selected')

Command Log

Find all elements following the .active li

cy.get('.left-nav').find('li.active').nextAll()

The commands above will display in the command log as:

screen shot 2017-03-23 at 2 05 32 pm

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

screen shot 2017-03-23 at 2 05 52 pm

See also