0
0
Cypresstesting~10 mins

cy.contains() for text matching 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 an element containing the text 'Submit'.

Cypress
cy.[1]('Submit')
Drag options to blanks, or click blank then click option'
Afind
Bget
Cclick
Dcontains
Attempts:
3 left
💡 Hint
Common Mistakes
Using cy.get() which selects by selector, not text.
Using cy.click() which performs a click, not a search.
2fill in blank
medium

Complete the code to find a button element containing the text 'Cancel'.

Cypress
cy.[1]('button', 'Cancel')
Drag options to blanks, or click blank then click option'
Acontains
Bget
Cfind
Dclick
Attempts:
3 left
💡 Hint
Common Mistakes
Using cy.get() with two arguments, which is invalid.
Using cy.find() which requires a parent element.
3fill in blank
hard

Fix the error in the code to correctly find a link containing 'Home'.

Cypress
cy.[1]('a', 'Home')
Drag options to blanks, or click blank then click option'
Aget
Bclick
Ccontains
Dfind
Attempts:
3 left
💡 Hint
Common Mistakes
Using cy.get() with :contains() selector causes errors.
Using cy.click() instead of a query command.
4fill in blank
hard

Fill both blanks to find a div containing the exact text 'Welcome'.

Cypress
cy.[1]('div').[2]('have.text', 'Welcome', { matchCase: true })
Drag options to blanks, or click blank then click option'
Acontains
Bshould
Cget
Dfind
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid syntax like cy.contains('div', { matchCase: true }, 'Welcome').
Using cy.find() without a parent element.
5fill in blank
hard

Fill all three blanks to find a button containing 'Save' and click it.

Cypress
cy.[1]('button', [2]).[3]()
Drag options to blanks, or click blank then click option'
Acontains
B'Save'
Cclick
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using cy.get() with text argument, which is invalid.
Forgetting to call click() after finding the element.