🎉 Introducing the Cypress Real World App—a new example app to learn, experiment, tinker, and practice application testing with Cypress.

Learn More


Improve this doc

Right click a DOM element.

.rightclick() will not open context menus native to the browser. .rightclick() should be used to test your app’s handling of right click related events such as contextmenu.


.rightclick(position, options)
.rightclick(x, y)
.rightclick(x, y, options)


Correct Usage

cy.get('.menu').rightclick()       // Right click on .menu
cy.focused().rightclick()          // Right click on el with focus
cy.contains('Today').rightclick()  // Right click on first el containing 'Today'

Incorrect Usage

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


position (String)

The position where the right click should be issued. The center position is the default position. Valid positions are topLeft, top, topRight, left, center, right, bottomLeft, bottom, and bottomRight.


x (Number)

The distance in pixels from the element’s left to issue the right click.

y (Number)

The distance in pixels from the element’s top to issue the right click.

options (Object)

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

Option Default Description
log true Displays the command in the Command log
force false Forces the action, disables waiting for actionability
multiple false Serially click multiple elements
timeout defaultCommandTimeout Time to wait for .rightclick() to resolve before timing out


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


No Args

Right click the menu



Specify a corner of the element to right click

Right click the top right corner of the DOM element.



Specify explicit coordinates relative to the top left corner

The right click below will be issued inside of the element (15px from the left and 40px from the top).

cy.get('#open-menu').rightclick(15, 40)


Force a right click regardless of its actionable state

Forcing a right click overrides the actionable checks Cypress applies and will automatically fire the events.

cy.get('#open-menu').rightclick({ force: true })

Force a right click with position argument

cy.get('#open-menu').rightclick('bottomLeft', { force: true })

Force a right click with relative coordinates

cy.get('#open-menu').rightclick(5, 60, { force: true })

Right click all buttons found on the page

By default, Cypress will error if you’re trying to right click multiple elements. By passing { multiple: true } Cypress will iteratively apply the right click to each element and will also log to the Command Log multiple times.

cy.get('.open-menu').rightclick({ multiple: true })

Right click with key combinations

The .rightclick() command may also be fired with key modifiers in combination with the .type() command in order to simulate character sequences while right clicking, such as ALT + rightclick. In order to keep the modifier key active, {release: false} should be passed to the options of the .type() command.

The following modifiers can be combined with .rightclick().

Sequence Notes
{alt} Activates the altKey modifier. Aliases: {option}
{ctrl} Activates the ctrlKey modifier. Aliases: {control}
{meta} Activates the metaKey modifier. Aliases: {command}, {cmd}
{shift} Activates the shiftKey modifier.

Command right click

// execute a CMD + right click on the .menu-item
// { release: false } is necessary so that
// CMD will not be released after the type command
cy.get('body').type('{cmd}', { release: false })



The element must first reach actionability

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



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


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

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


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

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

Command Log

Right click the DOM element


The commands above will display in the Command Log as:

Command log for right click

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

console.log for right click


Version Changes
3.5.0 .rightclick() command added

See also