Bird
0
0

How would you correctly perform a click on a hidden button with class hidden-btn using Cypress?

easy📝 Conceptual Q2 of 15
Cypress - Element Interactions
How would you correctly perform a click on a hidden button with class hidden-btn using Cypress?
Acy.get('.hidden-btn').click({ hidden: true });
Bcy.get('.hidden-btn').click();
Ccy.get('.hidden-btn').click(force=true);
Dcy.get('.hidden-btn').click({ force: true });
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct syntax

    Cypress requires the { force: true } option inside an object to click hidden elements.
  2. Step 2: Analyze options

    cy.get('.hidden-btn').click({ force: true }); uses correct syntax; B omits force, C uses invalid syntax, D uses a non-existent option.
  3. Final Answer:

    cy.get('.hidden-btn').click({ force: true }); -> Option D
  4. Quick Check:

    Use { force: true } inside click options [OK]
Quick Trick: Use { force: true } inside click options [OK]
Common Mistakes:
  • Omitting the force option for hidden elements
  • Using incorrect syntax like click(force=true)
  • Assuming a 'hidden' option exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes