Recall & Review
beginner
What is a value assertion in Cypress?
A value assertion checks if an element's value matches the expected value, like verifying the text inside an input field.
Click to reveal answer
beginner
How do you assert an attribute value in Cypress?
Use
.should('have.attr', 'attributeName', 'expectedValue') to check if an element has a specific attribute with the expected value.Click to reveal answer
beginner
Example: How to check if a button has the attribute
disabled in Cypress?Use
cy.get('button').should('have.attr', 'disabled'). This checks if the button has the disabled attribute, meaning it is not clickable.Click to reveal answer
beginner
What does
.should('have.value', 'text') do in Cypress?It asserts that the element's value property equals the given text, useful for input fields or textareas.
Click to reveal answer
beginner
Why are value and attribute assertions important in testing?
They confirm that the UI elements have the correct data and states, ensuring the app behaves as expected for users.
Click to reveal answer
Which Cypress command checks if an element has a specific attribute with a certain value?
✗ Incorrect
The command
should('have.attr', 'attributeName', 'value') checks for a specific attribute and its value.How do you assert the value of an input field in Cypress?
✗ Incorrect
Use
should('have.value', 'expectedValue') to check the input's value property.What does the assertion
.should('have.attr', 'disabled') verify?✗ Incorrect
Checking for the 'disabled' attribute confirms the element is disabled.
Which assertion would you use to check if a button's title attribute equals 'Submit'?
✗ Incorrect
Use
have.attr with the attribute name and expected value.Why is it better to use attribute assertions instead of text assertions for checking element states?
✗ Incorrect
Attributes like 'disabled' or 'checked' show actual element states, which text may not reveal.
Explain how to use Cypress to assert that an input field contains the expected value.
Think about how you check the text inside a form field.
You got /3 concepts.
Describe how attribute assertions help verify UI element states in Cypress tests.
Consider how a button can be disabled or enabled.
You got /3 concepts.