2.9 KiB
title, comments, description
| title | comments | description |
|---|---|---|
| prevuntil | true |
Get all previous 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.prevUntil will retry for the duration of the defaultCommandTimeout |
cy.prevUntil( selector )
Get all of the previous siblings of the elements until the selector.
cy.prevUntil( selector, *filter )
When a filter is provided, it retrieves all of the previous siblings up until the selector only if it matches that filter.
cy.prevUntil( element )
Get all of the previous siblings of the elements until the DOM node or jQuery object.
cy.prevUntil( element, *filter )
When a filter is provided, it retrieves all of the previous 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.prevUntil.
cy.prevUntil( selector, options ) cy.prevUntil( selector, filter, options ) cy.prevUntil( element, options ) cy.prevUntil( 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 before #nuts until #veggies
<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("#nuts").nextUntil("#veggies")
Command Log
Find all of the element's siblings before #nuts until #veggies
cy.get("#nuts").nextUntil("#veggies")
The commands above will display in the command log as:
When clicking on prevUntil within the command log, the console outputs the following: