# Right click failure while playback locally in Synthetic click path

**URL:** <https://community.dynatrace.com/t/right-click-failure-while-playback-locally-in-synthetic-click-path/42557>\
**Category:** Synthetic Monitoring\
**Tags:** browser-monitors, synthetic-monitoring\
**Created:** [November 10, 2023, 5:13am UTC](https://community.dynatrace.com/t/right-click-failure-while-playback-locally-in-synthetic-click-path/42557 "2023-11-10T05:13:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chaitanya](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chaitanya](https://community.dynatrace.com/u/chaitanya)\
**Post date:** [November 10, 2023, 5:13am UTC](https://community.dynatrace.com/t/right-click-failure-while-playback-locally-in-synthetic-click-path/42557/1 "2023-11-10T05:13:09Z")

</div>

Hi Folks,

Here I’m trying to record a click path workflow, able to record but not successfully playback the recorded events, facing an issue at right click event. I guess JavaScript event help us to resolve this, but I’m not supposed to be done this before.  
Can anyone help me with example please?

Best Regards

Chaitanya

---

<div class="post-metadata">

**Author:** ![RazTN7](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/raztn7/32/10208_2.png) [@RazTN7](https://community.dynatrace.com/u/RazTN7)\
**Post date:** [November 10, 2023, 5:35am UTC](https://community.dynatrace.com/t/right-click-failure-while-playback-locally-in-synthetic-click-path/42557/2 "2023-11-10T05:35:00Z")

</div>

Hello&nbsp;[@chaitanya](https://community.dynatrace.com/user/64258)&nbsp;,  
If you have already created the clickpath. Then select the particular browser monitoring --\> from top edit --\> click on recorded clickpath --\> give appropriate name --\> from dropdown event type select javascript --\> select the number after the event page where right-click event need to be added --\> then use below script for right click (from internet)

\<script\>  
const div = document.getElementById(“myDiv”);  
div.addEventListener(“contextmenu”, (e) =\> {e.preventDefault()});  
\</script\>

 ![RazTN7X_0-1699594226370.png](https://global.discourse-cdn.com/dynatrace/original/3X/e/f/efa37ec7d7277d8b0367039318446c052c010776.png)

Cheers!

RN

---

<div class="post-metadata">

**Author:** ![chaitanya](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chaitanya](https://community.dynatrace.com/u/chaitanya)\
**Post date:** [November 10, 2023, 6:01am UTC](https://community.dynatrace.com/t/right-click-failure-while-playback-locally-in-synthetic-click-path/42557/3 "2023-11-10T06:01:08Z")

</div>

Hi RN,  
Thanks for your response!  
Could you please take a look on below screenshot, is there anything we need to tweak?

Kind Regards

Chaitanya

 ![jserror2.JPG](https://global.discourse-cdn.com/dynatrace/original/3X/7/8/788c78decca15a93387b3c17ba2cadcaf12c60c0.jpeg)  
 ![jserror1.JPG](https://global.discourse-cdn.com/dynatrace/original/1X/0200d6c05f386b5bf67382fc949eaba10aa70423.jpeg)

---

<div class="post-metadata">

**Author:** ![chaitanya](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chaitanya](https://community.dynatrace.com/u/chaitanya)\
**Post date:** [November 10, 2023, 6:17am UTC](https://community.dynatrace.com/t/right-click-failure-while-playback-locally-in-synthetic-click-path/42557/4 "2023-11-10T06:17:52Z")

</div>

Hi RN,

error  
Playback error: Exception was thrown by the JavaScript code: Cannot read properties of null (reading ‘addEventListener’).

Best regards

Chaitanya

---

<div class="post-metadata">

**Author:** ![RazTN7](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/raztn7/32/10208_2.png) [@RazTN7](https://community.dynatrace.com/u/RazTN7)\
**Post date:** [November 10, 2023, 7:15am UTC](https://community.dynatrace.com/t/right-click-failure-while-playback-locally-in-synthetic-click-path/42557/5 "2023-11-10T07:15:40Z")

</div>

I’m not JS expert. You may give a try

[https://stackoverflow.com/questions/433919/javascript-simulate-right-click-through-code](https://stackoverflow.com/questions/433919/javascript-simulate-right-click-through-code)

[https://intellipaat.com/community/11740/javascript-simulate-right-click-through-code](https://intellipaat.com/community/11740/javascript-simulate-right-click-through-code)

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);  
}

Ref -&nbsp;[Browser clickpath events in Classic — Dynatrace Docs](https://docs.dynatrace.com/docs/shortlink/id-brower-clickpath-events#javascript)

> **[Browser clickpath events in Classic](https://docs.dynatrace.com/docs/observe/digital-experience/synthetic-monitoring/browser-monitors/browser-clickpath-events)**
>
> Learn about the event types created when recording a browser clickpath.

---

<div class="post-metadata">

**Author:** ![chaitanya](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chaitanya](https://community.dynatrace.com/u/chaitanya)\
**Post date:** [November 13, 2023, 9:00am UTC](https://community.dynatrace.com/t/right-click-failure-while-playback-locally-in-synthetic-click-path/42557/6 "2023-11-13T09:00:58Z")

</div>

Hi RN,

Thanks for your help and response.

Best regards

Chaitanya
