Skip to content

Instantly share code, notes, and snippets.

@pablocattaneo
Last active May 18, 2023 11:34
Show Gist options
  • Save pablocattaneo/97bce23b837d91fcbcae846ccfb43b4d to your computer and use it in GitHub Desktop.
Save pablocattaneo/97bce23b837d91fcbcae846ccfb43b4d to your computer and use it in GitHub Desktop.
// Source: https://docs.cypress.io/guides/references/best-practices#Selecting-Elements
// 1 - Add attribute data-cy="the_name_you_want" to the element that you want to select
// 2 - Use [data-cy='the_name_you_want']
// html
<button id="main" class="btn btn-large" data-cy="submit">Submit</button>
// my-test.cy.js
cy.get('[data-cy="submit"]').click()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment