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

3.5.0 - CypressError: Timed out retrying: Cannot read property 'defaultView' of null #5449

Closed
ilituchy opened this issue Oct 24, 2019 · 27 comments · Fixed by #5520
Closed

3.5.0 - CypressError: Timed out retrying: Cannot read property 'defaultView' of null #5449

ilituchy opened this issue Oct 24, 2019 · 27 comments · Fixed by #5520
Assignees
Labels
type: regression A bug that didn't appear until a specific Cy version release v3.5.0 🐛 Issue present since 3.5.0

Comments

@ilituchy
Copy link

ilituchy commented Oct 24, 2019

When I attempt to use a .select() on a <select> object, I am getting the posted error.

This is only the case when attempting to select something from the dropdown that DOES exist on the list. If I attempt to select a value that doesn't exist, I get the standard

Cypress error "CypressError: Timed out retrying: cy.select() failed because it could not find a single <option> with value or text matching...". 

I have previously been using this exact test successfully, and something must have changed causing it to error out. I find that even if I comment out this portion, similar errors follow with other commands later in the test.

This is the stack trace for the error.

CypressError: Timed out retrying: Cannot read property 'defaultView' of null
    at Object.cypressErr (http://app.locals/__cypress/runner/cypress_runner.js:104836:11)
    at Object.throwErr (http://app.locals/__cypress/runner/cypress_runner.js:104791:18)
    at Object.throwErrByPath (http://app.locals/__cypress/runner/cypress_runner.js:104823:17)
    at Object.retry (http://app.locals/__cypress/runner/cypress_runner.js:96197:16)
    at retryActionability (http://app.locals/__cypress/runner/cypress_runner.js:84998:19)
From previous event:
    at tryFn (http://app.locals/__cypress/runner/cypress_runner.js:96655:21)
    at whenStable (http://app.locals/__cypress/runner/cypress_runner.js:96690:12)
    at http://app.locals/__cypress/runner/cypress_runner.js:96240:16

I cannot seem to find anything called defaultView except within jQuery itself. I have tried searching this space for an answer, but cannot seem to figure out what the deal is.

The code that causes this error is:

cy.get('#inputDoctors').select(physicianName);

The get is successful, and I can confirm that element exists and the value is a valid option.

Steps to reproduce:

I believe that this error is somehow project internal, which for many reasons cannot be completely shared. However, I will create a very simple idea of what is going on:

<select id="inputDoctors>
  <option value="Doctor1">apples</option>
  <option value="Doctor2">oranges</option>
  <option value="Doctor3">bananas</option>
</select>
cy.get('#inputDoctors').select('Doctor1'); --> Fails with defaultView Error
cy.get('#inputDoctors').select('Doctor15'); --> Fails with cannot find value error

I understand it may be hard to help debug, but really anywhere you can point us to to start debugging this error is greatly appreciated.

Versions

Cypress: 3.5.0

@jennifer-shehane
Copy link
Member

Hey @ilituchy, you mentioned I have previously been using this exact test successfully, did you update to 3.5.0? Can you run the same code in 3.4.1 and see if this error displays. Thank you!

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Oct 24, 2019

Unfortunately, the example provided does not reproduce this error on our side in Chrome or Electron during cypress open.

We'll need a reproducible example in order to track down what exactly is causing this error.

Screen Shot 2019-10-24 at 1 04 28 PM

There are a few places where we are looking for defaultView within the Cypress code, mostly during clicking. Some places like el.ownerDocument.defaultView, likely there's something about your HTML that is causing this to evaluate as undefined

https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/mouse.js#L581

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Oct 24, 2019
@ilituchy
Copy link
Author

We have updated to 3.5, and still get the issue. We were able to add some wait statements that solved a few, but still run into issues with others. It is not always a select element, but can be input or anything else. Seems to just randomly have this issue.

My guess is that for some reason the elements it errors on are re-rendering perhaps? Because I was able to fix a few, I'm assuming that timing might be the issue. However, it wasn't before.

Do you have any good suggestions on setting delays / promises / waits for elements to be rendered? Obviously I know the standard methods, but they don't seem to be working always.

@ashley-maiden
Copy link

ashley-maiden commented Oct 24, 2019

I am also seeing CypressError: Timed out retrying: Cannot read property 'defaultView' of null in Cypress 3.5.0 when interacting with an iframe input. The same code does not generate an error in Cypress 3.4.1. I know iframes aren't natively supported right now but any tips would be helpful.

Custom command to interact with iframe elements (this still successfully selects buttons in the iframe):

Cypress.Commands.add('iframeElement', (selector) => {
  cy.log(selector)
    .get(`body > iframe`, { logfalse })
    .should(iframe => expect(iframe.contents().find(selector)).to.exist)
    .then(iframe => cy.wrap(iframe.contents().find(selector), { logfalse }))
})

Code to enter username in the username in the iframe input field :

cy.iframeElement('#username')
    .type('user_good') 

#username

@ilituchy
Copy link
Author

@ashley-maiden we are having the same error with iframes as well! We were able to get it to work in the past, most likely on an older version.

@jorisre
Copy link

jorisre commented Oct 25, 2019

Hi, got same error with stripe form during payment. Cypress can fill 2 fields of 3 and throw this error

@daniel-ogunnaike
Copy link

daniel-ogunnaike commented Oct 25, 2019

@ashley-maiden I am also having the same error when accessing an iFrame on 3.5.0 worked fine on 3.4.1 I'm not sure if the issue is the Electron bump or jQuery upgrade

@zitegeist
Copy link

yeah I've been getting the same issue too in my Stripe payment iFrames, the tests were fine and after the upgrade to 3.5.0 they just stopped working, rolled back to 3.4.1 and they work perfectly again, might be right with the JQuery upgrade @daniel-ogunnaike

@zbynek
Copy link

zbynek commented Oct 25, 2019

I'm not sure if the issue is the Electron bump or jQuery upgrade

Probably not Electron, the same failure happens in Chrome.

@daniel-ogunnaike
Copy link

I'm not sure if the issue is the Electron bump or jQuery upgrade

Probably not Electron, the same failure happens in Chrome.

Yeah, my money is on the jQuery upgrade

@sigujun
Copy link

sigujun commented Oct 25, 2019

Same for me, Tests are breaking in 3.5.0 but work fine in 3.4.1
‘CypressError: Timed out retrying: Cannot read property 'defaultView' of null’

@kmckee
Copy link

kmckee commented Oct 25, 2019

Same issue here. This test fails on 3.5.0 with the above error. I rolled back to 3.4.1 and it passes:

describe("Storybook", () => {
  beforeEach(() => {
    cy.visit("http://airbnb.io/react-dates/");
  });
  context("DateRangePicker", () => {
    it("should visit the default story in this collection", () => {
      cy.get('a[title="default"]').click()
      cy.get("#storybook-preview-iframe").then($iframe => {
        const doc = $iframe.contents();
        iget(doc, "#startDate").click();
        iget(doc, "#root > div > div:nth-child(2) > div > button").should(
          "have.text",
          "Show Info"
        );
      });
    });
  });
});

function iget(doc, selector) {
  return cy.wrap(doc.find(selector));
}

@pocketcolin
Copy link

pocketcolin commented Oct 25, 2019

Adding to this thread, I also just upgraded to 3.5 and can no longer complete Stripe payment iFrames.

cy.get('iframe[name^="__privateStripeFrame"]').then($iframe => {
    const $body = $iframe.contents().find('body')
    cy.wrap($body)
        .find('input[name="cardnumber"]', { timeout: 10000 })
        .type('4242')
        .type('4242')
        .type('4242')
        .type('4242')
})

Returns the same error:

CypressError: Timed out retrying: Cannot read property 'defaultView' of null

@realtebo
Copy link

realtebo commented Oct 25, 2019

OMG Same problem, same version, same use case. Damn...

The strange this is that find works well.
What fails is the type().
Also, click() fails in this situations.

I'll downgrade to 3.41.

@realtebo
Copy link

Yes, I confirm that with version 3.41 Stripe Iframes works well!

@adventmedia
Copy link

I had the same problem with Stripe iframes with 3.5, reverted to 3.4.1. What might be odd is that our implementation has separate iframes for the 3 inputs - first one works, next fails

@Akryum
Copy link
Contributor

Akryum commented Oct 28, 2019

Also happens to us in 3.5:
https://github.com/vuejs/vue-devtools/blob/7e63da196e51083df51aed10eda8f1d7f51bc82a/cypress/integration/components-tab.js#L83-L85

(Not using an iframe for the vue-devtools is not really an option.)

@bencatjakub
Copy link

I'm experiencing the same behaviour after upgrading to 3.5.0 and it's working on 3.4.1

Please fix this.

@kuceb kuceb changed the title CypressError: Timed out retrying: Cannot read property 'defaultView' of null 3.5.0 - CypressError: Timed out retrying: Cannot read property 'defaultView' of null Oct 29, 2019
@kuceb kuceb self-assigned this Oct 29, 2019
@cypress-bot cypress-bot bot added stage: work in progress and removed stage: needs information Not enough info to reproduce the issue labels Oct 29, 2019
@kuceb
Copy link
Contributor

kuceb commented Oct 29, 2019

I was able to reproduce and am working on a fix

@jennifer-shehane jennifer-shehane added the type: regression A bug that didn't appear until a specific Cy version release label Oct 29, 2019
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Oct 29, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 29, 2019

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

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Oct 29, 2019
@pazjing
Copy link

pazjing commented Oct 29, 2019

We have the exactly the same issue on iframe (test code works fine in 3.4.1 , but fail in 3.5.0)
Waiting for the fix.

Castigere added a commit to navikt/eux-web-app that referenced this issue Oct 30, 2019
* Mest sannsynlig tredjeparts depecency jQuery feil se issue cypress-io/cypress#5449
* Rettet liten feil i rereranse til en kode i en av testene
@WinstonN
Copy link

WinstonN commented Nov 2, 2019

Hello, I am seeing the same issue in 3.6.0 - downgrading to 3.4.1

@alexsegura
Copy link

@WinstonN are you sure you are using 3.6.0? The issue disappeared completely after upgrading for me 🤔
Here is the code I'm using to manipulate the iframe

https://github.com/coopcycle/coopcycle-web/blob/9311d2d26f44861ddbf12a5e266f7b2802872205/cypress/integration/checkout.spec.js#L94-L114

@jennifer-shehane
Copy link
Member

@WinstonN Please open a new issue detailing exactly how to reproduce the warning you are seeing - this bug for this situation has been fixed.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 5, 2019

Released in 3.6.0.

@rohitkadam19
Copy link

Was facing this issue with 3.5.0 but resolved in 3.6.1 version 👍

@realtebo
Copy link

I definitively love you so much.

I confirm all about sentry iframes are working well in 3.6.1.
Both 3.50 and 3.6.0 were NOT working.

Thanks more than a lot.

@jennifer-shehane jennifer-shehane added the v3.5.0 🐛 Issue present since 3.5.0 label Dec 10, 2019
@cypress-io cypress-io locked as resolved and limited conversation to collaborators Jan 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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