0
0
Cypresstesting~10 mins

cy.parent() and cy.children() in Cypress - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to get the parent element of the selected item.

Cypress
cy.get('.item').[1]()
Drag options to blanks, or click blank then click option'
Aparent
Bchildren
Cfind
Dsiblings
Attempts:
3 left
💡 Hint
Common Mistakes
Using children() instead of parent() to get the parent element.
2fill in blank
medium

Complete the code to get all children of the element with class 'list'.

Cypress
cy.get('.list').[1]()
Drag options to blanks, or click blank then click option'
Aparent
Bsiblings
Cchildren
Dclosest
Attempts:
3 left
💡 Hint
Common Mistakes
Using parent() instead of children() to get child elements.
3fill in blank
hard

Fix the error in the code to correctly get the parent of the element with id 'button'.

Cypress
cy.get('#button').[1]()
Drag options to blanks, or click blank then click option'
Aparent
Bfind
Cchildren
Dnext
Attempts:
3 left
💡 Hint
Common Mistakes
Using children() instead of parent().
Using next() which selects sibling elements, not parent.
4fill in blank
hard

Fill both blanks to get the children of the parent of the element with class 'active'.

Cypress
cy.get('.active').[1]().[2]()
Drag options to blanks, or click blank then click option'
Aparent
Bchildren
Csiblings
Dfind
Attempts:
3 left
💡 Hint
Common Mistakes
Using children() first then parent(), which changes the selection order.
Using siblings() instead of children().
5fill in blank
hard

Fill all three blanks to get the children of the parent of the element with id 'nav', then find elements with class 'item'.

Cypress
cy.get('#nav').[1]().[2]().[3]('.item')
Drag options to blanks, or click blank then click option'
Aparent
Bchildren
Cfind
Dsiblings
Attempts:
3 left
💡 Hint
Common Mistakes
Using siblings() instead of children() or find().
Incorrect order of commands.