W3cubDocs

/Cypress

dblclick

Double-click a DOM element.

Syntax

.dblclick()
.dblclick(options)

Usage

Correct Usage

cy.get('button').dblclick()          // Double click on button
cy.focused().dblclick()              // Double click on el with focus
cy.contains('Welcome').dblclick()    // Double click on first el containing 'Welcome'

Incorrect Usage

cy.dblclick('button')          // Errors, cannot be chained off 'cy'
cy.window().dblclick()         // Errors, 'window' does not yield DOM element

Arguments

options (Object)

Pass in an options object to change the default behavior of .dblclick().

Option Default Description
log true Displays the command in the Command log
timeout defaultCommandTimeout Time to wait for .dblclick() to resolve before timing out

Yields

  • .dblclick() yields the same subject it was given from the previous command.

Examples

No Args

Double click an anchor link

cy.get('a#nav1').dblclick() // yields the <a>

Notes

Actionability

The element must first reach actionability

.dblclick() is an “action command” that follows all the rules defined here.

Rules

Requirements

  • .dblclick() requires being chained off a command that yields DOM element(s).

Assertions

  • .dblclick() will automatically wait for the element to reach an actionable state.

  • .dblclick() will automatically wait for assertions you've chained to pass.

Timeouts

  • .dblclick() can time out waiting for the element to reach an actionable state.

  • .dblclick() can time out waiting for assertions you've added to pass.

Command Log

Double click on a calendar schedule

cy.get('[data-schedule-id="4529114"]:first').dblclick()

The commands above will display in the Command Log as:

Command Log dblclick

When clicking on dblclick within the command log, the console outputs the following:

console.log dblclick

See also

© 2017 Cypress.io
Licensed under the MIT License.
https://docs.cypress.io/api/commands/dblclick.html