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

Asserting something should('not.have.value') / should('not.be.visible') logs element as "undefined" #5763

Closed
davidzambrana opened this issue Nov 21, 2019 · 10 comments · Fixed by #8612
Labels
pkg/driver This is due to an issue in the packages/driver directory type: regression A bug that didn't appear until a specific Cy version release v3.5.0 🐛 Issue present since 3.5.0

Comments

@davidzambrana
Copy link

davidzambrana commented Nov 21, 2019

Current behavior:

What I try to check in my test is that a given field should not have an empty value as the following code shows.

cy.get('[data-test=ext-referral-form-btn]').should('be.visible').click();
cy.get('[data-test=ext-referral-formSuccess-code]').should('not.have.value','');

Such assertion is set right after a click where I submit form data and wait for ext-referral-formSuccess-code in the next view (after loading) to have an empty value.

The test passes but in the log I see the following:

notempty

The assertion seems to go well but the cypress logger doesn't work as expected, logging the field names as undefined. Actually, if I wait some ms after the click just to give some time to Cypress to see the fields I see the following:

successfields

I also see the correct data logged if instead of asserting should('not.have.value','') I set should('have.value','whatever').

Desired behavior:

I expect to see the correct value of the field names I am asserting using should('not.have.value','') in a view that is onloading instead of undefined.
It seems that when Cypress logs the data it doesn't have the value at hand, and only explicitly waiting some time it is able to read it and log it properly.

Steps to reproduce: (app code and test code)

You can verify this behavior by setting an assertion like cy.get('yourThing').should('not.have.value','') right after submitting a form.

  • Fill up required data
  • submit the form
  • assert that an element in the next view should('not.have.value','')
  • See the Cypress log

Versions

Cypress 3.6.1
Ubuntu Linux 18.04.3 LTS
Electron 73
Also using Cucumber pre-processor 1.16.2

@frankind

This comment has been minimized.

@jennifer-shehane
Copy link
Member

We'll need a reproducible example provided - test code + html in order to investigate. Likely it has to do with something rerendering in the DOM at a strange time when we're trying to access the element.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Dec 16, 2019
@frankind
Copy link

frankind commented Dec 16, 2019

We'll need a reproducible example provided - test code + html in order to investigate. Likely it has to do with something rerendering in the DOM at a strange time when we're trying to access the element.

This is the code

it('should found "xxx" element not to be visible', () => {
    cy.visit('https://docs.cypress.io/guides/overview/why-cypress.html')
    cy.get('xxx').should('not.be.visible')
  })

This is the result in Cypress3.4.1
image
This is the result in Cypress3.8.0
image

@jennifer-shehane jennifer-shehane added type: regression A bug that didn't appear until a specific Cy version release v3.5.0 🐛 Issue present since 3.5.0 and removed stage: needs information Not enough info to reproduce the issue labels Dec 16, 2019
@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Dec 16, 2019
@jennifer-shehane
Copy link
Member

jennifer-shehane commented Dec 16, 2019

Perfect, thank you! I verified this was introduced in 3.5.0.

This only happens during the .should('not.be.visible') assertion specifically (and from original comment the .should('not.have.value'). Does not happen in .should('not.exist') for example.

@jennifer-shehane jennifer-shehane added the pkg/driver This is due to an issue in the packages/driver directory label Dec 16, 2019
@davidzambrana
Copy link
Author

Thanks for providing the example @frankind

@s0oft
Copy link

s0oft commented Jan 30, 2020

Any news on this?

@MarkConway94
Copy link

hey team, just noticed the same thing a month after upgrading to cypress version 4.0.2.
Any news on a fix?
I have lots of tests that are now giving false positives 😢

@jennifer-shehane jennifer-shehane changed the title Asserting something should('not.have.value','') on an onloading view is logged as "undefined" Asserting something should('not.have.value') / should('not.be.visible') logs element as "undefined" Jul 9, 2020
@jennifer-shehane
Copy link
Member

Just adding a smaller repro and confirming that this still occurs in 4.9.0.

<html>
<body>
</body>
</html>
it('should find "xxx" element not to be visible', () => {
  cy.visit('index.html')
  cy.get('xxx').should('not.be.visible')
})

3.4.1

Screen Shot 2020-07-09 at 12 42 53 PM

3.5.0+

Screen Shot 2020-07-09 at 12 39 52 PM

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 18, 2020

The code for this is done in cypress-io/cypress#8612, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 29, 2020

Released in 5.3.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v5.3.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Sep 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/driver This is due to an issue in the packages/driver directory type: regression A bug that didn't appear until a specific Cy version release v3.5.0 🐛 Issue present since 3.5.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants