cypress have attribute code example

Example 1: cypress have attribute

cy.get('selector')
	.should('have.attr', 'aria-checked', 'true')

Example 2: cypress element css

cy
  .get('nav')                          // yields 

Example 3: cypress check element have attribute

cy.get('input').invoke('attr', 'placeholder').should('contain', 'username')

Example 4: cypress check element have attribute

// have.attr comes from chai-jquery
cy.get('#header a').should('have.attr', 'href', '/users')

Tags:

Misc Example