Cannot read property 'ownerDocument' of null
See original GitHub issueCurrent behavior:
Clicking on a chart element causes the retry to fail.
This is the error:
Desired behavior:
The click action should work as expected. The click should select the chart in the following point:
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:
- Created 3 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
andmouseDownPhase
: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 ofmouseUpPhase
because it’s right below the mouse pointer.But it doesn’t exist any more when
getFirstCommonAncestor()
starts. That’s whygetFirstCommonAncestor()
loops up to the<html>
tag andnull
.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?@sainthkh You may want to VPN into east coast US because this site loads incredibly slow in Asia.