Skip to content

cy.click() yields no error, but wrong element is clicked #6165

@badeball

Description

@badeball

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 with force: 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.

diff --git a/packages/driver/src/cy/commands/actions/click.js b/packages/driver/src/cy/commands/actions/click.js
index f6e0cb7f5..c4add683e 100644
--- a/packages/driver/src/cy/commands/actions/click.js
+++ b/packages/driver/src/cy/commands/actions/click.js
@@ -207,6 +207,8 @@ module.exports = (Commands, Cypress, cy, state, config) => {
         onReady (fromElViewport, forceEl) {
           const clickEvents = mouse.click(fromElViewport, forceEl)
 
+          console.log(clickEvents);
+
           return {
             clickEvents,
           }

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:

2020-01-15-135643_5360x1440_scrot

With force: true:

2020-01-15-135707_5360x1440_scrot

Versions

Cypress v3.8.2, Arch Linux, Chrome 79.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions