10 Nov 2023 05:13 AM
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
Solved! Go to Solution.
10 Nov 2023 05:35 AM
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>
Cheers!
RN
10 Nov 2023 06:01 AM
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
10 Nov 2023 06:17 AM
Hi RN,
error
Playback error: Exception was thrown by the JavaScript code: Cannot read properties of null (reading 'addEventListener').
Best regards
Chaitanya
10 Nov 2023 07:15 AM
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
13 Nov 2023 09:00 AM
Hi RN,
Thanks for your help and response.
Best regards
Chaitanya