mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-24 09:29:35 -05:00
2.1 KiB
2.1 KiB
title, comments, description
| title | comments | description |
|---|---|---|
| siblings | true |
Get the siblings DOM elements of each element in the set of matched DOM elements.
| Returns | the new DOM element(s) found by the command. |
| Timeout | cy.siblings will retry for the duration of the defaultCommandTimeout |
cy.siblings()
Get the siblings of each DOM element in the set of matched DOM elements.
cy.siblings( selector )
Get the siblings of each DOM element in the set of matched DOM elements filtered by a selector.
Options
Pass in an options object to change the default behavior of cy.siblings.
cy.siblings( options ) cy.siblings( selector, options )
| Option | Default | Notes |
|---|---|---|
log |
true |
whether to display command in command log |
timeout |
defaultCommandTimeout |
Total time to retry getting the element |
Usage
Get the siblings of each li.
<ul>
<li>Home</li>
<li>Contact</li>
<li class="active">Services</li>
<li>Price</li>
</ul>
// returns all other li's in list
cy.get(".active").siblings()
Selector Usage
Get siblings of element with class active.
// returns <li class="active">Services</li>
cy.get("li").siblings(".active")
Command Log
Get the siblings of element with class active
cy.get(".left-nav").find("li.active").siblings()
The commands above will display in the command log as:
When clicking on siblings within the command log, the console outputs the following: