Files
cypress/docs/source/api/commands/parents.md
T
2017-05-19 12:01:36 -04:00

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()
screen shot 2015-11-27 at 2 02 59 pm

When clicking on the parents command within the command log, the console outputs the following:

screen shot 2015-11-27 at 2 03 32 pm

Related