← Back to library
Cypressassertionsadvancedv10+

Chain multiple assertions with .and()

Use .and() (alias for .should()) to assert multiple properties on the same element without re-querying.

1it('asserts several properties on the same element', () => {
2  cy.visit('/profile');
3
4  // .and() chains assertions on the same subject — no extra cy.get() calls
5  cy.get('[data-testid="plan-badge"]')
6    .should('be.visible')
7    .and('have.text', 'Pro')
8    .and('have.attr', 'data-plan', 'pro')
9    .and('have.class', 'badge-pro');
10
11  // Works on inputs too
12  cy.get('[name="email"]')
13    .should('be.visible')
14    .and('not.be.disabled')
15    .and('have.attr', 'type', 'email')
16    .and('have.value', 'user@test.com');
17});
#chained assertions#and#should#multiple#chain