Improve this doc

Get all following siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.

The querying behavior of this command matches exactly how .nextUntil() works in jQuery.


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


Correct Usage

cy.get('div').nextUntil('.warning') // Yield siblings after 'div' until '.warning'

Incorrect Usage

cy.nextUntil()                  // Errors, cannot be chained off 'cy'
cy.location().nextUntil('path') // Errors, 'location' does not yield DOM element


selector (String selector)

The selector where you want finding next siblings to stop.

element (DOM node, jQuery Object)

The element where you want finding next siblings to stop.

filter (String selector)

A selector used to filter matching DOM elements.

options (Object)

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

Option Default Description
log true Displays the command in the Command log
timeout defaultCommandTimeout Time to wait for .nextUntil() to resolve before timing out


  • .nextUntil() yields the new DOM element(s) it found.



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

  <li id="fruits" class="header">Fruits</li>
  <li id="veggies" class="header">Vegetables</li>
  <li id="nuts" class="header">Nuts</li>
//returns [<li>cucumbers</li>, <li>carrots</li>, <li>corn</li>]



  • .nextUntil() requires being chained off a command that yields DOM element(s).


  • .nextUntil() will automatically retry until the element(s) exist in the DOM.

  • .nextUntil() will automatically retry until assertions you've chained all pass.


  • .nextUntil() can time out waiting for the element(s) to exist in the DOM.

  • .nextUntil() can time out waiting for assertions you've added to pass.

Command Log

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


The commands above will display in the Command Log as:

Command Log nextUntil

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

Console Log nextUntil

See also