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

not.be.visible assertion fails when element does not exist in DOM and Stripe JS SDK is imported #5270

Closed
bahalperin opened this issue Oct 2, 2019 · 3 comments · Fixed by #6344 or Flygsand/site#83
Labels
pkg/driver This is due to an issue in the packages/driver directory topic: assertions ✔️ type: bug

Comments

@bahalperin
Copy link

Current behavior:

Normally when asserting that an element is not visible (using .should('not.be.visible')), if the element does not exist in the DOM, the assertion passes.

For some reason, simply by including the Stripe JS SDK in the head of the document (following the instructions here), the not.be.visible assertion fails (by timing out when retrying to find the element) when the element is not in the DOM.

There is a work around by checking not.exist before not.be.visible

Desired behavior:

The behavior should be consistent whether or not the Stripe SDK is imported

Steps to reproduce: (app code and test code)

Repro can be found in this repo

Versions

Cypress 3.4.1

@jennifer-shehane
Copy link
Member

I was able to reproduce this in 3.8.1. Code to reproduce below:

with_stripe.html

<!DOCTYPE html>
<head>
  <script src="https://js.stripe.com/v3"></script>
</head>
<body>
</body>
</html>

without_stripe.html

<!DOCTYPE html>
<head>
</head>
<body>
</body>
</html>

spec.js

it('without stripe asserting "not visible"', () => {
  cy.visit('without_stripe.html')
  cy.get('.foo').should('not.be.visible') // passes
})

it('with stripe asserting "not visible"', () => {
  cy.visit('with_stripe.html')
  cy.get('.foo').should('not.be.visible') // falsely fails because can't find element
})

it('with stripe asserting "not exists" then "not visible"', () => {
  cy.visit('with_stripe.html')
  cy.get('.foo')
    .should('not.exist')
    .and('not.be.visible') // passes
})

Screen Shot 2020-01-03 at 5 14 04 PM

Stripe injects an iframe into the html, which may have something to do with it, but I tried injecting a simple iframe into the html and it did not fail like with the Stripe script.

Screen Shot 2020-01-03 at 5 21 37 PM

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Jan 3, 2020
@jennifer-shehane jennifer-shehane added pkg/driver This is due to an issue in the packages/driver directory topic: assertions ✔️ labels Jan 3, 2020
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress stage: needs review The PR code is done & tested, needs review labels Feb 6, 2020
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Feb 14, 2020
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: needs review The PR code is done & tested, needs review stage: work in progress labels Mar 18, 2020
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Mar 24, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 24, 2020

The code for this is done in cypress-io/cypress#6344, 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 Mar 30, 2020

Released in 4.3.0.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Mar 30, 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 topic: assertions ✔️ type: bug
Projects
None yet
2 participants