Consider the following Cypress test code snippet:
cy.get('#hidden-btn').click()The button with id hidden-btn is styled with display: none;. What will happen when this test runs?
cy.get('#hidden-btn').click()
Think about how Cypress handles clicks on elements that are not visible.
Cypress does not allow clicking on elements that are hidden (e.g., with display: none;). It throws an error indicating the element is not visible.
You want to check that an element with class .secret-message is hidden on the page. Which Cypress assertion is correct?
Check Cypress documentation for visibility assertions.
The correct assertion to check if an element is hidden is should('not.be.visible'). The others are invalid or do not exist in Cypress.
Given this test code:
cy.get('#hidden-input').type('hello')The input with id hidden-input has visibility: hidden;. The test fails. Why?
cy.get('#hidden-input').type('hello')
Consider Cypress's rules about interacting with hidden elements.
Cypress requires elements to be visible to interact with them. An element with visibility: hidden; is considered hidden, so typing fails.
You want to click a button that is hidden with display: none;. Which Cypress command option allows clicking it anyway?
Look for the Cypress click option that overrides visibility checks.
The { force: true } option forces Cypress to click even if the element is hidden.
Which approach is best to test the presence and state of hidden elements in Cypress?
Think about how to verify an element is present but hidden.
The best practice is to check the element exists in the DOM with should('exist') and then verify it is hidden with should('not.be.visible'). This confirms presence and hidden state without changing the page.