mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-19 06:38:45 -05:00
1.8 KiB
1.8 KiB
title, comments, description
| title | comments | description |
|---|---|---|
| parents | true |
Get the parents DOM elements of the DOM elements.
| Returns | the new DOM element(s) found by the command. |
| Timeout | cy.parents will retry for the duration of the defaultCommandTimeout |
cy.parents()
Get the ancestors of each element in the current set of matched elements.
cy.parents( selector )
Get the ancestors of each element in the current set of matched elements filtered by selector
Options
Pass in an options object to change the default behavior of cy.parents.
cy.parents( options ) cy.parents( 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 parents of the active li
cy.get("li.active").parents()
Selector Usage
Get the parents with class nav of the active li
cy.get("li.active").parents(".nav")
Command Log
Get the parents of the active li
cy.get("li.active").parents()
When clicking on the parents command within the command log, the console outputs the following: