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

242
Views
Cypress does not recognize list element

I am trying to run Cypress tests for a Angular based Frontend. In this application there is a list-component that includes several message-list-items. The problem I'm currently facing is that Cypress does not recognize all message-list-items displayed.I want to compare the expected number of messages with the actual number of displayed messages. At the moment I do not understand Cypress's behavior. Sometimes Cypress recognizes all message-list-items and sometimes a single message is skipped (totally random which one). In the HTML the message-list-item exists and I can see the message-list-item beeing rendered too. Cypress just does not highlight or recognize it at all.

Here is a screenshot of the message-list-item in the HTML HTML message-list-items available

A screenshot from Cypress logs Cypress log output

The code to acess the message-list-items:

 cy.wait(2000).then(() =>
      cy.get('message-list')
        .each(($el, index) => {
          cy.wrap($el).then(() => (resultCounter += 1));
        })
        .then(() =>
          expect(resultCounter).equals(
            expectedMessageCounter
          )
        )
    );

Anyone faced the same problem? Thanks in advance!

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

The easiest way to do this without any flaky results is

cy.get('message-list-item')
  .should('have.length', expectedMessageCounter)

Because you have a .should(), Cypress will retry up to 4 seconds for the correct length.

You do not need to .each().

about 4 years ago · Santiago Gelvez 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!