Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test run successfully but if ran again and again then fails in between #9270

Closed
pmahit05 opened this issue Nov 22, 2020 · 2 comments
Closed

Comments

@pmahit05
Copy link

pmahit05 commented Nov 22, 2020

My Test failing in between. It failing to find element but some times it runs without error.

I tried to perform same on google and found same issue.

describe('My First Test', () => {
 before(() => {
  cy.visit('https://www.google.com/');
 })

it('Search Validation', () => {
 cy.get('input[name="q"]').type('cypress');
 cy.get('form[name="f"]').submit();
 cy.get('a[href="https://docs.cypress.io/guides/overview/why-cypress.html"]').should('be.visible');
 cy.get('input[name="q"]').clear().type('Angular');
})
}) 

Above test fails in between saying form[name="f"] not found.
Any idea why this inconsistent behavior

Cypress version 5.6.0

@bahunov
Copy link

bahunov commented Dec 10, 2020

Could be due to many reasons. Some backend calls that's not taken in to account etc..

@jennifer-shehane
Copy link
Member

The server requests don't always complete within the 5 seconds that Cypress is looking for the form to render.

So either assert on the server requests completely or give more time than 5 secs to find the form element, cy.get('form[name="f"]', { timeout: 30000 }).submit();

Passing

Screen Shot 2020-12-11 at 4 07 47 PM

Failing

Screen Shot 2020-12-11 at 4 08 39 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants