on
01 May 2024
12:00 PM
- edited on
08 Jun 2026
11:40 AM
by
HannahM
pointerdown, pointerup, mouseup, click) so the application processes the interaction correctly. .click() action, but instead expects a combination of pointer and mouse events to be fired in a specific order.
click, pointerdown, pointerup, mouseover)function triggerevent(element)
{
var parameters1 = { isTrusted: true, pressure: 0.5, type: "pointerdown", bubbles: true, cancelable: true, cancelBubble: false };
var parameters2 = { isTrusted: true, bubbles: true, cancelable: true, cancelBubble: false };
var evt1 = new PointerEvent("pointerdown", parameters1);
element.dispatchEvent(evt1);
var evt2 = new PointerEvent("pointerup", parameters1);
element.dispatchEvent(evt2);
var evt3 = new MouseEvent("mouseup", parameters2);
element.dispatchEvent(evt3);
var evt4 = new MouseEvent("click", parameters2);
element.dispatchEvent(evt4);
}
var element = document.querySelector("#layout-inner > dt-common-navigation").shadowRoot.querySelector("nav > nav > ul > li:nth-child(9) > a");
triggerevent(element);
shadowRoot. This is required only if your application uses Shadow DOM..shadowRoot portion and use a standard querySelector() instead.
isTrusted property..click() work in Synthetic Browser Monitors?
📖 Synthetic Troubleshooting Map
📖 How to interact with trusted events in a Browser Clickpath Monitor
📖 How to perform a right-click in a Browser Clickpath Synthetic Monitor
📖 How to inspect and add the shadow DOM elements into synthetic script events
Hi @Mareeswaran , thank you for your suggestion. I have tried replacing all the CSS locators with DOM and it works during replay but is there anyway we could set up Dynatrace to capture the DOM locators by default (instead of CSS) while recording a flow?
@shalnw Unfortunately, we don't have way to make the synthetic recorder to capture the DOM locators by default and we need to inspect & add the DOM locators manually.
Thanks @Mareeswaran , I have added the DOM locators/ events and the screenshots to my recording. The playback click path replays the expected flow and the screenshots are correct. But when I go to Analyse executions to view results, it shows just the website's homepage. Is this inconsistency expected for Shadow DOM events?
@shalnw Yes. If the application uses the shadowDOM elements, Dynatrace Synthetic Recorder extension not supported for recording the shadowDOM elements. You can refer the community article for that How to inspect and add the shadow DOM elements into synthetic script events.
Hi
I tried out this JS script method and currently encountering the error "Playback error: Exception was thrown by the JavaScript code: Cannot read properties of null (reading 'shadowRoot')."
I'm not sure what I am missing here.
Thank you.
Hi @kenyu216
I suspect that target window may be different one and that is the reason its unable to identify the selector. You can inspect the element and check if there is any iframe are available. If so, you need to use the relevant target window like ruxitWin[0].frames[0]