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

Cypress's dblclick does not function the same way as a user double clicking #3224

Closed
calvinballing opened this issue Jan 25, 2019 · 8 comments · Fixed by #3030
Closed

Cypress's dblclick does not function the same way as a user double clicking #3224

calvinballing opened this issue Jan 25, 2019 · 8 comments · Fixed by #3030
Assignees

Comments

@calvinballing
Copy link
Contributor

calvinballing commented Jan 25, 2019

Current behavior:

Firing Cypress's dblclick() does not behave the same way as a user double clicking an element. Specifically, if there is no special meaning for a double click, then when a user double clicks, the first click event triggers a click action. However, with dblclick(), if nothing is defined specifically for a double click, then the element is put in focus, but the action associated with a single click does not occur. See test example below.

Desired behavior:

Firing Cypress's dblclick() behaves the same way as a user double clicking an element. I would expect that in both the examples below Cypress would navigate to the "mission" page, because a user double clicking on a link would be interpreted as a single click event if no special meaning is defined for the double click.

Steps to reproduce:

it('Example of successful single click', () => {
  cy.visit('https://www.google.com');
  cy.contains('About').click();
  cy.contains('Our mission is to');
});

it('Example of unsuccessful double click', () => {
  cy.visit('https://www.google.com');
  cy.contains('About').dblclick();
  cy.contains('Our mission is to');
});

Versions

Windows 10
Cypress 3.1.4
Chrome 71

@calvinballing
Copy link
Contributor Author

calvinballing commented Jan 25, 2019

Also, for context, the reason I was trying to test this is I want to ensure that a particular button will only trigger the associated action once, rather than twice. Right now we have a button that will trigger it's associated event multiple times if rapidly clicked in succession, but which should be locking out the user immediately after it is used the first time. I've also tried .click().click(), and .type('{enter}{enter}') but neither of these work for my particular circumstance.

@calvinballing
Copy link
Contributor Author

calvinballing commented Jan 25, 2019

Possible consideration, what if .click() could take an argument telling it to click x number of times on the same element repeatedly, separated by delays of y milliseconds?

@kuceb
Copy link
Contributor

kuceb commented Jan 25, 2019

@calvinballing this is a known issue and will be fixed alongside #2956 Currently we just fire the dblclick event, but we will change that to issue 2 clicks as well.

What is your app code regarding this behavior?

will trigger it's associated event multiple times if rapidly clicked in succession, but which should be locking out the user immediately after it is used the first time

for example, are you using rxjs throttle or debounce, or are you using the detail property on the click event?

@kuceb kuceb added the stage: needs information Not enough info to reproduce the issue label Jan 25, 2019
@kuceb kuceb self-assigned this Jan 25, 2019
@kuceb
Copy link
Contributor

kuceb commented Jan 25, 2019

as a workaround, you can try this:

cy.get('button#foobar')
  .trigger('click', {detail: 1})
  .trigger('click', {detail: 2})
  .trigger('dblclick', {detail: 2})

@calvinballing
Copy link
Contributor Author

calvinballing commented Jan 28, 2019

@bkucera Using multiple instances of .trigger('click') was successful for me as a workaround for simulating a double click. Since I'm on the QA side, while I know what the current issue is, I'm not certain what method our dev team will implement to ensure it behaves as expected going forward. In similar instances we have had in the past the solutions we've used have worked fine though.

@jennifer-shehane jennifer-shehane added stage: ready for work The issue is reproducible and in scope and removed stage: needs information Not enough info to reproduce the issue labels Jan 29, 2019
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: ready for work The issue is reproducible and in scope stage: needs review The PR code is done & tested, needs review labels Aug 8, 2019
@scipper
Copy link

scipper commented Aug 30, 2019

cy.get("selector").click().dblclick() works as well.

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Sep 6, 2019
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: needs review The PR code is done & tested, needs review stage: work in progress labels Sep 25, 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 7, 2019
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Oct 11, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 11, 2019

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

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 23, 2019

Released in 3.5.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants