0
0
Cypresstesting~10 mins

cy.find() within parent 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 find a button inside a parent element using Cypress.

Cypress
cy.get('.parent').[1]('button').click();
Drag options to blanks, or click blank then click option'
Afind
Bcontains
Cget
Dchildren
Attempts:
3 left
💡 Hint
Common Mistakes
Using get instead of find which searches the whole document.
Using contains which looks for text content, not element selectors.
2fill in blank
medium

Complete the code to find a child element with class 'item' inside a parent with id 'list'.

Cypress
cy.get('#list').[1]('.item').should('be.visible');
Drag options to blanks, or click blank then click option'
Afind
Bparent
Cget
Dchildren
Attempts:
3 left
💡 Hint
Common Mistakes
Using get which searches the entire document.
Using parent which goes up the DOM tree.
3fill in blank
hard

Fix the error in the code to correctly find a span inside a div with class 'container'.

Cypress
cy.get('.container').[1]('span').should('exist');
Drag options to blanks, or click blank then click option'
Aparent
Bfind
Csiblings
Dclosest
Attempts:
3 left
💡 Hint
Common Mistakes
Using parent which goes up the DOM tree.
Using siblings which looks at elements at the same level.
4fill in blank
hard

Fill both blanks to find all list items inside a nav element and check their count.

Cypress
cy.get('nav').[1]('li').[2]('have.length', 5);
Drag options to blanks, or click blank then click option'
Afind
Bshould
Cchildren
Dexpect
Attempts:
3 left
💡 Hint
Common Mistakes
Using children which only finds direct children, not all descendants.
Using expect which is not chained like this in Cypress.
5fill in blank
hard

Fill all three blanks to find a button inside a form, click it, and verify it is disabled.

Cypress
cy.get('form').[1]('button').[2]().[3]('be.disabled');
Drag options to blanks, or click blank then click option'
Afind
Bclick
Cshould
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using get instead of find which searches the whole document.
Forgetting to chain click before the assertion.