Bird
0
0

Which of the following is a valid way to click a button with class submit-btn using cy.click()?

easy📝 Conceptual Q2 of 15
Cypress - Element Interactions
Which of the following is a valid way to click a button with class submit-btn using cy.click()?
Acy.find('.submit-btn').click()
Bcy.get('.submit-btn').click()
Ccy.click('.submit-btn')
Dcy.clickButton('.submit-btn')
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct chaining syntax

    In Cypress, cy.get() selects elements, then .click() clicks them. So cy.get('.submit-btn').click() is correct.
  2. Step 2: Check invalid options

    cy.click() does not accept selectors directly, cy.find() is used on elements, and cy.clickButton() is not a Cypress command.
  3. Final Answer:

    cy.get('.submit-btn').click() -> Option B
  4. Quick Check:

    Correct click syntax = cy.get(selector).click() [OK]
Quick Trick: Always select element first with cy.get() before click [OK]
Common Mistakes:
  • Trying to pass selector directly to cy.click()
  • Using non-existent commands like cy.clickButton()
  • Using cy.find() without context

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes