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

2.8 KiB

title, comments, description
title comments description
nextuntil true

Get all following siblings of each DOM element in the set of matched DOM elements up to, but not including, the element matched by the selector

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

cy.nextUntil( selector )

Get all of the next siblings of the elements until the selector.

cy.nextUntil( selector, *filter )

When a filter is provided, it retrieves all of the following siblings up until the selector only if it matches that filter.

cy.nextUntil( element )

Get all of the next siblings of the elements until the DOM node or jQuery object.

cy.nextUntil( element, *filter )

When a filter is provided, it retrieves all of the following siblings up until the DOM node or jQuery object only if it matches that filter.

Options

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

cy.nextUntil( selector, options ) cy.nextUntil( selector, filter, options ) cy.nextUntil( element, options ) cy.nextUntil( element, filter, options )

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

Usage

Find all of the element's siblings following #veggies until #nuts

<ul>
  <li id="fruits" class="header">Fruits</li>
  <li>apples</li>
  <li>oranges</li>
  <li>bananas</li>
  <li id="veggies" class="header">Vegetables</li>
  <li>cucumbers</li>
  <li>carrots</li>
  <li>corn</li>
  <li id="nuts" class="header">Nuts</li>
  <li>walnuts</li>
  <li>cashews</li>
  <li>almonds</li>
</ul>
//returns [<li>cucumbers</li>, <li>carrots</li>, <li>corn</li>]
cy.get("#veggies").nextUntil("#nuts")

Command Log

Find all of the element's siblings following #veggies until #nuts

cy.get("#veggies").nextUntil("#nuts")

The commands above will display in the command log as:

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

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

screen shot 2017-03-23 at 2 18 01 pm

Related