question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'ownerDocument' of null

See original GitHub issue

Current behavior:

Clicking on a chart element causes the retry to fail.

This is the error:

image

Desired behavior:

The click action should work as expected. The click should select the chart in the following point:

image

Test code to reproduce

context('Actions', () => {

  beforeEach(() => {
    cy.visit('https://demo.spotfire.cloud.tibco.com/spotfire/wp/analysis?file=/Public/Airbnb%20Boston%20Listings')
  })

  it('select chart value', () => {
    cy.wait(6000) // Give time for the chart to render. Ideally, this should wait on the specific HTML element.
    cy.get('div[title="Property Type Distribution"]').parent().parent().parent().click(150, 60) // This click will fail.
  })

})

Second version of code to reproduce that does not rely on cy.wait():

context('Actions', () => {

  beforeEach(() => {
    cy.visit('https://demo.spotfire.cloud.tibco.com/spotfire/wp/analysis?file=/Public/Airbnb%20Boston%20Listings')
  })

  it('select chart value', () => {
    cy.get('div[title="Property Type Distribution"]').as('chartTitle').parent().parent().parent()
      .within(el => {
        cy.get('div.sf-element-canvas-image').invoke('attr', 'sf-busy').should('eq', 'false')
        cy.wrap(el).as('chart').click(150, 60) // This click will fail.
      })
  })

})

Versions

Windows 10, Chrome or Electron, any version.

  "devDependencies": {
    "cypress": "^4.3.0"
  },

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sainthkhcommented, Apr 7, 2020

Thankfully, the site wasn’t slow in South Korea. It might be because of the world’s fastest Internet South Korea has.

Anyway, I researched the problem and found the cause.

cy.click() command doesn’t issue native mouse event, but it only simulates it (#311).

To run that simulation, we check mouseUpPhase and mouseDownPhase:

https://github.com/cypress-io/cypress/blob/069b22b0d55e42ecfcddfc8f1cabf539dac0266d/packages/driver/src/cy/mouse.js#L530-L534

And then, check if the target element of mouseDownPhase exists:

https://github.com/cypress-io/cypress/blob/069b22b0d55e42ecfcddfc8f1cabf539dac0266d/packages/driver/src/cy/mouse.js#L542-L545

This code doesn’t consider this case: what if the target element of mouseUpPhase doesn’t exist?

That’s the cause of the problem in this issue.

When you click an item in the chart, the app tries to make a drag area, div.sf-canvas-drag-cursor. That’s the target element of mouseUpPhase because it’s right below the mouse pointer.

Screenshot from 2020-04-07 17-39-18

But it doesn’t exist any more when getFirstCommonAncestor() starts. That’s why getFirstCommonAncestor() loops up to the <html> tag and null.

The solution might be just returning the mouseDownPhase element.

Implementation isn’t hard, but I’m asking this just in case to avoid breaking change:

When this code was written, was there a specific case that mouseUpPhase always exists?

1reaction
jennifer-shehanecommented, Apr 6, 2020

@sainthkh You may want to VPN into east coast US because this site loads incredibly slow in Asia.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'ownerDocument' of undefined ...
I think my view is returning proper JSON but now data is not being added to the .mainContent div. It gives this error:...
Read more >
Can not read property ownerDocument of null · Issue #542
I am getting TypeError: Cannot read property 'ownerDocument' of null even if all the required props are passed to Container and element.
Read more >
Cannot read property 'ownerDocument' of undefined
I put a child component called <page-buttons> in my main Vue component. This component has some buttons floating on the page.
Read more >
cannot read properties of null (reading 'ownerdocument')
I am getting TypeError: Cannot read property 'ownerDocument' of null even if all the required props are passed to Container and element. Line...
Read more >
Cannot read property ownerDocument of null
actionButton2: Cannot read property 'ownerDocument' of null Error: An error occurred while executing On click at Linegenix.Location_NewEdit.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found