Wildcards on Classes in Cypress

Sometimes the classes are seemingly randomly-generated (at least in part). Here’s two methods you can use to help find them:

cy.get(‘[class*=”something”]’) — this finds the element with “something” anywhere within the class.

cy.get(‘*[class^=”something”]’) — this finds the element with “something” at the beginning of the class.

cy.get(‘[class$=”something”]’) - this finds the element with “something” specifically at the end of the class.

Previous
Previous

Randomizing Stripe test credit cards in Cypress

Next
Next

Useful debugging code for Cypress