Ilesh Darji


Top 10 Cypress Commands Every Tester Should Know

Cypress provides a powerful set of commands that make end-to-end testing intuitive and robust. Whether you’re just starting out or looking to sharpen your skills, these 10 commands are fundamental for writing effective tests.


1. cy.visit()

Navigates to a specified URL.

cy.visit('https://example.com')

2. cy.get()

Selects DOM elements using CSS selectors.

cy.get('input[name="email"]')

3. cy.contains()

Finds an element that contains specific text.

cy.contains('Submit')

4. cy.click()

Simulates a click action on an element.

cy.get('button[type="submit"]').click()

5. cy.type()

Types text into an input field.

cy.get('input[name="email"]').type('hello@cypress.io')

6. cy.should()

Makes an assertion about an element or value.

cy.get('h1').should('contain.text', 'Welcome')

7. cy.url() and cy.title()

Check the current page’s URL or title.

cy.url().should('include', '/dashboard')
cy.title().should('eq', 'Dashboard - My App')

8. cy.request()

Makes HTTP requests without using the UI.

cy.request('GET', '/api/users')

9. cy.intercept()

Intercepts network requests for mocking or spying.

cy.intercept('GET', '/api/products', { fixture: 'products.json' })

10. cy.fixture()

Loads static data from a fixture file.

cy.fixture('user.json').then((user) => {
  cy.get('input[name="email"]').type(user.email)
})

🚀 Final Thoughts

These Cypress commands form the foundation of most test cases. Once you master them, you can build on top of them using custom commands, page objects, and plugins.


Next in Series: Page Object Model in Cypress: Best Practices