Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!