commands.js 411 B

12345678910111213141516171819202122232425
  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. })
  13. /**
  14. *
  15. */
  16. Cypress.Commands.add(
  17. 'containing',
  18. {
  19. prevSubject: true
  20. },
  21. (subject, rx) => {
  22. return subject.filter(() => { return rx.test(Cypress.$(this).text()) })
  23. }
  24. )