Troubleshooting
Articles about how to solve the most common problems
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
HannahM
Dynatrace Guru
Dynatrace Guru

Summary

When creating Dynatrace Browser Clickpath Synthetic monitors, a standard left‑click isn’t always sufficient. Some web applications rely on context‑menu interactions that require a right‑click action.
This article explains how to perform a right‑click in a Browser Clickpath Synthetic monitor by using a JavaScript event, allowing you to reliably simulate advanced user interactions during Synthetic executions
 

 

How to Perform a Right‑Click Using a JavaScript Event

Step 1 – Identify the Element to Right‑Click

  1. Go to the relevant page in a Chrome browser.

  2. Right-click on the element you want to interact with on the page and select 'Inspect'. The element will then be shown in Developer Tools. Inspect.png

     

Step 2 – Copy the JavaScript Selector

  1. Right-click on the element in the Web Developer Tools -> Copy -> Copy JS path.

     
    DevTools.png

     

Step 3 – Update the JavaScript snippet

  1. Paste the JavaScript selector in the value below the element.

    function rightClick(element){
      var evt = element.ownerDocument.createEvent('MouseEvents');
      var RIGHT_CLICK_BUTTON_CODE = 2; // the same for FF and IE
      evt.initMouseEvent('click', true, true,
          element.ownerDocument.defaultView, 1, 0, 0, 0, 0, false,
          false, false, false, RIGHT_CLICK_BUTTON_CODE, null);
      return !element.dispatchEvent(evt);
    }
    var element = document.querySelector('button[id="testid"]'); //Replace with the element which you want to right-click.
    rightClick(element);
     

 

Step 4 – Add a JavaScript Event to the Browser Clickpath

  1. Add a new event to the monitor, where you need to right-click and paste in the updated snippet above. 

    HannahM_3-1703869880685.png

     

Frequently Asked Questions

Why doesn’t right‑click work in recorded Browser Clickpaths?

The Dynatrace Synthetic Recorder doesn’t always capture context‑menu interactions. Recorded click actions are simple left-click, so right‑click actions will fail during playback and must be replaced with JavaScript events. 

Is this supported in Dynatrace Synthetic Monitoring?

Yes. Dynatrace Browser Clickpath Synthetic monitors support JavaScript events, which can be used to trigger advanced interactions such as right‑click actions when required. 

When should I use JavaScript events in Browser Clickpaths?

JavaScript events should be used when standard click or keystroke actions are unreliable, especially for dynamic UI elements, custom context menus, or JavaScript‑heavy applications. 

 

What's Next

If the previous steps don't resolve the issue, open a chat and provide a link to the monitor, along with the troubleshooting steps you have already completed.

 

Related reading

📖  Synthetic Troubleshooting Map

📖  How to perform a click event using JavaScript on Browser Clickpath Synthetic monitors

📖  How to add an XPath locator in a Browser Clickpath Monitor script

📖  Browser clickpath JavaScript events

Version history
Last update:
‎14 May 2026 02:26 PM
Updated by:
Comments
ChadTurner
DynaMight Legend
DynaMight Legend

Thanks for sharing! 

mwater07
Visitor

Hello ,

I have tried to implement that but I am getting the below error once i have playback the record.

Playback error: Exception was thrown by the JavaScript code: Cannot read properties of null (reading 'ownerDocument')

 

Is there any recomendation to overcome this issue?

Thank you