Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

135
Vistas
Get first 3 words of a phrase

Can someone advise how i can check that a table row has a specific text. i tried to do it with a command as such:

Cypress.Commands.add('start', (text) => {
   cy.contains('td',text)
})

Then i do cy.start('Specify a selector') in my test

My scenario is i am searching a table using first 3 words of a phrase..It has to be first 3 and if not found it should fail. if it has the first two text correct it should not find it..It has to be verified by the first 3 text itself. Assuming that i have the text

Specify a selector to filter DOM elements containing the text

in my test i am writing:

cy.start('td','Specify a selector') i see the test passing but if i put "elements" it also passes

How can i achieve this please.

Thank you

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could use a regex instead of a simple string, and that should accomplish what you'd like. The ^ symbol signifies that this should be the beginning of the matched string.

Cypress.Commands.add('start', (text) => {
   cy.contains('td', RegExp(`^${text}`))
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda