commands.js 227 B

123456789101112
  1. /**
  2. * Get an element by its label
  3. *
  4. * ex: cy.getByLabel('input', 'Search')
  5. */
  6. Cypress.Commands.add(
  7. 'getByLabel',
  8. (selector, label) => {
  9. return cy.contains('label', label)
  10. .parent()
  11. .find(selector)
  12. })