Home > Net >  How can I find and click button element in cypress by the text on the button
How can I find and click button element in cypress by the text on the button

Time:02-15

I am having trouble finding a way of locating this element with cypress. I dont want to use the class name due to its complexity, and would like to use "Support" to keep my code clean.

<button type="button" >Support</button>

I have attempted cy.get('button').contains('Support').click() without success.

CodePudding user response:

There's another variation of .contains() that will give you just the "Support" button

cy.contains('button', 'Support')
  • Related