Recall & Review
beginner
What does the
exist assertion check in Cypress?The
exist assertion checks if an element is present in the DOM, regardless of whether it is visible or not.Click to reveal answer
beginner
Explain the difference between
exist and be.visible assertions.exist checks if the element is in the DOM, while be.visible checks if the element is actually visible to the user on the page.Click to reveal answer
beginner
How do you check if an element contains specific text using Cypress?
Use the
have.text assertion to verify that an element's text content exactly matches the expected string.Click to reveal answer
beginner
Write a Cypress assertion to check if a button with id
#submit is visible.cy.get('#submit').should('be.visible');
Click to reveal answer
intermediate
Why is it important to use
be.visible instead of just exist when testing user interactions?Because an element might exist in the DOM but be hidden or covered, so
be.visible ensures the user can actually see and interact with it.Click to reveal answer
Which Cypress assertion checks if an element is present in the DOM?
✗ Incorrect
The
exist assertion verifies that the element is in the DOM, regardless of visibility.What does
be.visible assertion ensure?✗ Incorrect
be.visible checks that the element is visible on the page and can be seen by the user.How do you check if an element's text exactly matches 'Hello World'?
✗ Incorrect
have.text checks for exact text match inside the element.Which assertion would fail if the element is hidden but present in the DOM?
✗ Incorrect
be.visible fails if the element is hidden, even if it exists in the DOM.What is the correct Cypress command to check if a button with class '.btn' exists?
✗ Incorrect
The
exist assertion confirms the element is present in the DOM.Describe the purpose of the Cypress assertions:
exist, be.visible, and have.text.Think about presence, visibility, and text content separately.
You got /3 concepts.
Explain why using
be.visible is important when testing user interactions compared to just exist.Consider what the user actually experiences on the page.
You got /3 concepts.