Cypress: CypressError: Timed out retrying: Expected to find element: '#name', but never found it.

Created on 23 Mar 2020  路  4Comments  路  Source: cypress-io/cypress

Hi ,

I am facing timeout issue running cypress test in circle ci .

below is my HTML

<form id="new-firmware-image-form" class="form _2Gc1lUsI1nsEgxQUQbSMFO">
  <div class="stack-panel _1ymm4z8MDZqYQmnUWe9GZI vertical gutter form-controls">
     <label class="formLabel _2MvCRziMA8n3GScnUvYDg3">
        <div class="stack-panel _1ymm4z8MDZqYQmnUWe9GZI horizontal gutter content">
            <input id="name" name="name" maxlength="128" type="text" class="textbox            _1gUJmIoz_Ch9J6ReOuQEjz" value="">
            <div class="_22txD77MIM87j_XKmBPzE5 small dialog-error">&nbsp;</div
    < label/>

My code to get the name text box element .

 get firmwareName() {
        return cy.get("#new-firmware-image-form").within(el => {
            cy.get("#name");
        });
    }

Issue :

works perfectly fine in local run.
Fails with below error in CI

CypressError: Timed out retrying: Expected to find element: '#name', but never found it.

Dont want to use cy.wait()

Please help me how can i solve this ?

Most helpful comment

That is quick Response Thanks @jennifer-shehane .
As i said ,
Screenshot 2020-03-23 at 12 18 50
these is piece of code for which it fails in CI every time . where as in local i don't see any issue it works perfectly fine.
I am not sure what more information i can provide here as i am also unsure why is it failing ONLY in ci.
I went through debugging step but no luck . I have attached Screen shot if that helps to have look

All 4 comments

Please go through our steps for debugging why something fails locally versus in CI: https://on.cypress.io/using-cypress-faq#Why-do-my-Cypress-tests-pass-locally-but-not-in-CI

I can't recreate this behavior with the HTML and test code provided.

index.html

<html>
<body>
<form id="new-firmware-image-form" class="form _2Gc1lUsI1nsEgxQUQbSMFO">
  <div class="stack-panel _1ymm4z8MDZqYQmnUWe9GZI vertical gutter form-controls">
    <label class="formLabel _2MvCRziMA8n3GScnUvYDg3">
      <div class="stack-panel _1ymm4z8MDZqYQmnUWe9GZI horizontal gutter content">
        <input id="name" name="name" maxlength="128" type="text" class="textbox_1gUJmIoz_Ch9J6ReOuQEjz" value="">
        <div class="_22txD77MIM87j_XKmBPzE5 small dialog-error">&nbsp;</div> 
      </div>
    <label />
  </div>
</form>
</body>
</html>

spec.js

it("test", () => {
  cy.visit('index.html')
  cy.get("#new-firmware-image-form").within(el => {
    cy.get("#name")
  })
})

Screen Shot 2020-03-23 at 6 37 38 PM

Unfortunately we have to close this issue as there is not enough information to reproduce the problem. This does not mean that your issue is not happening - it just means that we do not have a path to move forward.

Please comment in this issue with a reproducible example and we will consider reopening the issue.

That is quick Response Thanks @jennifer-shehane .
As i said ,
Screenshot 2020-03-23 at 12 18 50
these is piece of code for which it fails in CI every time . where as in local i don't see any issue it works perfectly fine.
I am not sure what more information i can provide here as i am also unsure why is it failing ONLY in ci.
I went through debugging step but no luck . I have attached Screen shot if that helps to have look

Seen a lot of this too! Curious if anyone has any insights

There is a package in cypress called as waitUntil. The link is here
I am also looking for the solution of this problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

carloscheddar picture carloscheddar  路  3Comments

szabyg picture szabyg  路  3Comments

jennifer-shehane picture jennifer-shehane  路  3Comments

jennifer-shehane picture jennifer-shehane  路  3Comments

brian-mann picture brian-mann  路  3Comments