Cypress uses jQuery-style selectors combined with a chainable assertion API. Every command is automatically retried until it passes or times out — no manual waits needed.
Finding Elements
Ctrl+Enter
HTML
CSS
JS
Preview
Best practice: add data-cy attributes to your elements so tests don't break when styles change.
<button data-cy="login-btn">Login</button>Assertions with .should()
Ctrl+Enter
HTML
CSS
JS
Preview
Assertions Practice
Selector and assertion sandbox
Ctrl+Enter
HTML
CSS
JS
Preview
.then() for Custom Logic
Ctrl+Enter
HTML
CSS
JS
Preview
Use .then() when you need to extract a value and run custom expectations that .should() can't express.
Aliases
cy.get('[data-cy="submit"]').as('submitBtn')
cy.get('@submitBtn').click()
cy.get('@submitBtn').should('be.disabled')Aliases (as()) let you name elements and reuse them without re-querying the DOM.