-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
cy.click() yields no error, but wrong element is clicked #6165
Comments
Gosh, looking through the changelog and I see that this has been troublesome for a while. I've added some waiting to my tests to ensure that there's no animation going it, but the problem still resides. |
The idea behind this behavior is to mimic the behavior that the browser enforces when a real user clicks. If a user in a real browser clicks on an element and mid-click another DOM element animates in front of where their mouse cursor is, the rest of the Mouse events will fire on the new element that is now directly behind the mouse cursor. This is expected behavior with the correct workaround being to use I can see how the 'Actual Element Clicked' console log is a bit confusing though since some of the events were fired on another element. That being said, there could be some weird edge case where this is doing funky things outside of what I just described. If that is the case - we'll need a reproducible example provided to investigate. |
Alright, I understand. There's without a doubt a discrepancy between browser-behavior and Cypress-behavior in my case. I will see if I can create a minimal example. For those curious, it's related to Google Maps and overlays. |
I've added a minimal example here. The example-application will zoom the map upon clicking the marker. In Cypress, this only works with Unforunately, this entails google maps, as mentioned above. Hence, 1) the example is somewhat cluttered from technical point of view and thus not "minimal" and 2) it requires an API key to run. Do you posses a key yourself to make it run? If not, I am able to host the example at a hidden location which I can provide you in confidence (due to API restrictions). You can contact me on |
Possibly related to #5805 |
Yes, I can check. FYI, in your screenshot, it appears you are not using
IE. there's a regression somewhere after v3.4.0. |
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided. |
This issue has been closed due to inactivity. |
I previously reported erroneous behavior in regards to determining visibility. With #6000 and v3.8.2, this was indeed fixed, but it uncovered another issue.
Current behavior:
cy.get("...").click({ force: false })
no longer yields an error, but the click-handler of the DOM element is never invoked. If I however invoke it withforce: true
, its click-handler is invoked.I modified Cypress with the patch shown below and was quite surprised to find that the actually clicked element is not the element described in the console as "Actual Element Clicked". The actual element clicked is an ancestor of my subject, which does not have any click-handler at all.
Desired behavior:
If
cy.get("...").click({ force: false })
doesn't yield an error, it should invoke the click-handler of the subject and not some other element determined by some heuristic.Test code to reproduce
I'm having a hard coming up with a minimal example to reproduce the issue. I'm posting the output of the commands in hope that it will be enough to spark some ideas. If this is not enough, then I'll give it another shot.
With
force: false
:With
force: true
:Versions
Cypress v3.8.2, Arch Linux, Chrome 79.
The text was updated successfully, but these errors were encountered: