0
0
Cypresstesting~10 mins

Parent commands 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 a button.

Cypress
cy.get('button').[1]()
Drag options to blanks, or click blank then click option'
Achildren
Bfind
Csiblings
Dparent
Attempts:
3 left
💡 Hint
Common Mistakes
Using children() instead of parent()
Using find() which looks for descendants, not parents
2fill in blank
medium

Complete the code to get the grandparent element of a div.

Cypress
cy.get('div').parent().[1]()
Drag options to blanks, or click blank then click option'
Achildren
Bsiblings
Cparent
Dfind
Attempts:
3 left
💡 Hint
Common Mistakes
Using siblings() which selects elements at the same level
Using children() which goes down the DOM tree
3fill in blank
hard

Fix the error in the code to get the parent of an element with class 'item'.

Cypress
cy.get('.item').[1]()
Drag options to blanks, or click blank then click option'
Aparent
Bchildren
Cparents
Dchild
Attempts:
3 left
💡 Hint
Common Mistakes
Using parents() which returns all ancestors, not just the direct parent
Using children() which goes down the DOM tree
4fill in blank
hard

Fill both blanks to get the parent element and then find its child with class 'title'.

Cypress
cy.get('section').[1]().[2]('.title')
Drag options to blanks, or click blank then click option'
Aparent
Bchildren
Cfind
Dsiblings
Attempts:
3 left
💡 Hint
Common Mistakes
Using siblings() which selects elements at the same level
Using children() instead of find() for nested search
5fill in blank
hard

Fill all three blanks to get the parent of an element with id 'list', then get its siblings, and finally find a child with class 'active'.

Cypress
cy.get('#list').[1]().[2]().[3]('.active')
Drag options to blanks, or click blank then click option'
Aparent
Bsiblings
Cfind
Dchildren
Attempts:
3 left
💡 Hint
Common Mistakes
Using children() instead of siblings() to get elements at the same level
Using children() instead of find() to search inside elements