0
0
Cypresstesting~10 mins

Negative assertions (not) 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 check that the element does NOT contain the text 'Error'.

Cypress
cy.get('.message').should('not.[1]', 'Error')
Drag options to blanks, or click blank then click option'
Aexist
Bhave.text
Ccontain
Dbe.visible
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'have.text' instead of 'contain' which checks exact text, not partial.
Forgetting to add 'not.' before the assertion.
2fill in blank
medium

Complete the code to assert that the button is NOT disabled.

Cypress
cy.get('button.submit').should('not.[1]')
Drag options to blanks, or click blank then click option'
Abe.enabled
Bvisible
Cexist
Dbe.disabled
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'be.enabled' inside 'not.' which would check the opposite of what is intended.
Omitting 'not.' and checking only 'be.disabled'.
3fill in blank
hard

Fix the error in the code to assert the input field does NOT have the value 'admin'.

Cypress
cy.get('#username').should('not.[1]', 'admin')
Drag options to blanks, or click blank then click option'
Ahave.value
Bbe
Chave
Dcontain
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'be.have.value' which is invalid syntax.
Omitting 'not.' and checking only 'have.value'.
4fill in blank
hard

Fill both blanks to assert the element with class 'alert' is NOT visible and does NOT exist in the DOM.

Cypress
cy.get('.alert').should('[1].be.visible').and('[2].exist')
Drag options to blanks, or click blank then click option'
Anot
Bbe
Dhave
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'be' instead of 'not' to negate assertions.
Mixing 'have' with 'exist' which is incorrect.
5fill in blank
hard

Fill all three blanks to assert that the checkbox with id 'agree' is NOT checked, NOT disabled, and NOT visible.

Cypress
cy.get('#agree').should('[1].be.checked').and('[2].be.disabled').and('[3].be.visible')
Drag options to blanks, or click blank then click option'
Anot
Dbe
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'be' instead of 'not' to negate assertions.
Mixing 'not' and 'be' incorrectly in the chain.