Skip to content

I.rightClick() ​

Click on an element or at a position using the right mouse button.

Usage ​

js
// right click an element at its center
I.rightClick(element: string)

// right click with an offset from the top-left corner of an element
I.rightClick(element: string, x: number, y: number)

// right click at a position from the top-left corner of the viewport
I.rightClick(x: number, y: number)

Parameters ​

ParameterTypeDescription
elementstringThe element to click on — by text, CSS, or XPath selector
xnumberHorizontal offset in pixels from the left edge of the element or viewport
ynumberVertical offset in pixels from the top edge of the element or viewport

Examples ​

Right click by text ​

javascript
I.rightClick("Map");

This targets an element that best matches the text "Map" (case-insensitive), based on:

  • the text content of the element,
  • associated <label> elements,
  • descriptive attributes such as aria-label, title, alt-text
  • adjacent text

Right click by CSS ​

javascript
I.rightClick("#map");

This targets an element that matches the CSS selector #map exactly.

If there are multiple matches, UI-licious will target the element nearest to elements with the most recent interactions.

Right click by XPath ​

javascript
I.rightClick("//canvas[@data-test-id='map']");

This targets an element that matches the XPath selector //canvas[@data-test-id='map'] exactly.

If there are multiple matches, UI-licious will target the element nearest to elements with the most recent interactions.

Right click using element offset ​

javascript
I.rightClick("#map", 100, 10);

This right clicks at an offset from the #map element with an offset of 100px to the right and 10px down from the top-left corner of the element.

Right click using viewport offset ​

javascript
I.rightClick(500, 300);

This right clicks at 500px right and 300px down from the top-left corner of the viewport (the visible portion of the page).