Bird
0
0

Which of the following is the correct way to write a test in Cypress to check if a button with id 'submit' is visible?

easy📝 Syntax Q3 of 15
Cypress - Basics and Setup
Which of the following is the correct way to write a test in Cypress to check if a button with id 'submit' is visible?
Adriver.findElement(By.id('submit')).isDisplayed();
Bcy.get('#submit').should('be.visible');
Cpage.locator('#submit').isVisible();
Dassert(button.visible);
Step-by-Step Solution
Solution:
  1. Step 1: Recognize Cypress syntax

    Cypress uses cy.get() to select elements and .should() for assertions.
  2. Step 2: Identify other tool syntaxes

    driver.findElement(By.id('submit')).isDisplayed(); is Selenium syntax, C is Playwright, D is invalid.
  3. Final Answer:

    cy.get('#submit').should('be.visible'); -> Option B
  4. Quick Check:

    Cypress syntax = cy.get + should [OK]
Quick Trick: Cypress uses cy.get() and should() for assertions [OK]
Common Mistakes:
  • Mixing Selenium or Playwright syntax with Cypress
  • Using invalid assertion methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes