title |
---|
nextAll |
Get all following siblings of each DOM element in a set of matched DOM elements.
{% note info %}
The querying behavior of this command matches exactly how {% url .nextAll()
http://api.jquery.com/nextAll %} works in jQuery.
{% endnote %}
.nextAll()
.nextAll(selector)
.nextAll(options)
.nextAll(selector, options)
{% fa fa-check-circle green %} Correct Usage
cy.get('.active').nextAll() // Yield all links next to `.active`
{% fa fa-exclamation-triangle red %} Incorrect Usage
cy.nextAll() // Errors, cannot be chained off 'cy'
cy.getCookies().nextAll() // Errors, 'getCookies' does not yield DOM element
{% 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 | Description |
---|---|---|
log |
true |
{% usage_options log %} |
timeout |
{% url defaultCommandTimeout configuration#Timeouts %} |
{% usage_options timeout .nextAll %} |
{% yields changes_dom_subject_or_subjects .nextAll %}
<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()
<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')
{% requirements dom .nextAll %}
{% assertions existence .nextAll %}
{% timeouts existence .nextAll %}
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:
{% imgTag /img/api/nextall/next-all-traversal-command-for-the-dom.png "Command Log nextAll" %}
When clicking on nextAll
within the command log, the console outputs the following:
{% imgTag /img/api/nextall/all-next-elements-are-logged-in-console.png "Console Log nextAll" %}
- {% url
.next()
next %} - {% url
.nextUntil()
nextuntil %} - {% url
.prevAll()
prevall %}