Skip to content
masterclass Buddy

Cypress · Matcher

have.attr

The have.attr matcher checks that a selected HTML element has an attribute. It can also verify the attribute's value.

Last updated

Syntax

cy.get(selector).should('have.attr', attributeName[, expectedValue])

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • cy.get
  • should
  • Cypress.isBrowser
  • Accessibility Testing

Source: Why Cypress? End-to-end, component & accessibility testing | Cypress Documentation. Checked 2026-11-03.