cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Right click failure while playback locally in Synthetic click path

chaitanya
Participant

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

5 REPLIES 5

RazTN7
Dynatrace Champion
Dynatrace Champion

Hello @chaitanya ,
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

Cheers!

RN

 

Have a nice day!

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

Hi RN,

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

Best regards

Chaitanya

RazTN7
Dynatrace Champion
Dynatrace Champion

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

https://stackoverflow.com/questions/433919/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 - https://docs.dynatrace.com/docs/shortlink/id-brower-clickpath-events#javascript

https://docs.dynatrace.com/docs/shortlink/id-brower-clickpath-events#javascript-event-api

 

Have a nice day!

Hi RN,

Thanks for your help and response.

Best regards

Chaitanya

Featured Posts