Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

132
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda