mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-20 15:20:23 -05:00
2.3 KiB
2.3 KiB
title, comments, description
| title | comments | description |
|---|---|---|
| nextall | true |
Get all following siblings of each DOM element in the set of matched DOM elements.
| Returns | the new DOM element(s) found by the command. |
| Timeout | cy.nextAll will retry for the duration of the defaultCommandTimeout |
cy.nextAll()
Get all of the next siblings of the elements.
cy.nextAll( selector )
When a selector is provided, it retrieves all of the following siblings only if it matches that selector.
Options
Pass in an options object to change the default behavior of cy.nextAll.
cy.nextAll( options ) cy.nextAll( selector, 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 .second
<ul>
<li>apples</li>
<li class="second">oranges</li>
<li>bananas</li>
<li>pineapples</li>
<li>grapes</li>
</ul>
//returns [<li>bananas</li>, <li>pineapples</li>, <li>grapes</li>]
cy.get(".second").nextAll()
Selector Usage
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>
//returns <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:
When clicking on nextAll within the command log, the console outputs the following: