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

**URL:** <https://community.dynatrace.com/t/how-to-add-an-xpath-locator-in-a-browser-clickpath-monitor-script/40063>\
**Category:** Troubleshooting\
**Tags:** browser-monitors, synthetic-monitoring\
**Created:** [June 7, 2023, 3:24pm UTC](https://community.dynatrace.com/t/how-to-add-an-xpath-locator-in-a-browser-clickpath-monitor-script/40063 "2023-06-07T15:24:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hannahmac](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/hannahmac/32/41823_2.png) [@hannahmac](https://community.dynatrace.com/u/hannahmac)\
**Post date:** [June 7, 2023, 3:24pm UTC](https://community.dynatrace.com/t/how-to-add-an-xpath-locator-in-a-browser-clickpath-monitor-script/40063/1 "2023-06-07T15:24:46Z")

</div>

## Summary

Browser Clickpath Monitors support DOM and CSS locators out of the box. This covers most scenarios, but for some applications, an XPath locator is needed. This article will explain how to select one.

## Steps to find the XPath locator

1. Open the relevant page in a Chrome Browser

2. Right-click on the element to be clicked in the Browser clickpath monitor

3. Select Inspect (this will open Dev Tools)

4. Right-click on the element that is highlighted

5. Choose Copy \> Copy XPath

## Adding an XPath locator into your Monitor

You can either use the XPath locator directly as a locator or use a JavaScript event for clicking.

### Steps to add an XPath locator into an existing Click or Keystrokes event&nbsp;

1. Open the Browser Clickpath Monitor\> Settings \> Recorded clickpath page

2. Open the relevant Click or Keystroke event you would like to update

3. In the Edit element locators section, modify the 1st locator to be DOM type and replace the Input section with

4. Save changes

### Steps to add a JavaScript event to click on XPath locator

1. Open the Browser Clickpath Monitor\> Settings \> Recorded clickpath page

2. Click Add synthetic event  
&nbsp;  

3. Name the event, select JavaScript from the select synthetic event drop down and pick the event you would like you new event to be added after.

4. Click Add Synthetic event

5. Paste the following snippet into the black box

6. Replace xpath with the XPath captured previously

7. Save changes

## What’s Next

If none of the previous steps resolved the issue, open a chat and provide a link to the monitor you’re updating and the configuration steps you have already completed.

### **Related reading**

📖&nbsp;&nbsp;[Synthetic Troubleshooting Map](https://community.dynatrace.com/topic/250426)

📖&nbsp; [Configure Browser Monitors](https://docs.dynatrace.com/docs/observe/digital-experience/synthetic-monitoring/browser-monitors/configure-browser-monitors)

📖&nbsp; [Browser Monitor JavaScript events](https://docs.dynatrace.com/docs/observe/digital-experience/synthetic-monitoring/browser-monitors/browser-clickpath-events#javascript)

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [June 8, 2023, 6:53pm UTC](https://community.dynatrace.com/t/how-to-add-an-xpath-locator-in-a-browser-clickpath-monitor-script/40063/2 "2023-06-08T18:53:06Z")

</div>

Great Write up thanks&nbsp;[@HannahM](https://community.dynatrace.com/user/1433)

---

<div class="post-metadata">

**Author:** ![daniel\_severino](https://avatars.discourse-cdn.com/v4/letter/d/b487fb/32.png) [@daniel\_severino](https://community.dynatrace.com/u/daniel_severino)\
**Post date:** [August 27, 2023, 3:34pm UTC](https://community.dynatrace.com/t/how-to-add-an-xpath-locator-in-a-browser-clickpath-monitor-script/40063/3 "2023-08-27T15:34:13Z")

</div>

I know that the post is very old but Could you tell me how to implement a condition if the by chance the object (dropdown) has not been load on the page to throw an exception, please?

---

<div class="post-metadata">

**Author:** ![hannahmac](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/hannahmac/32/41823_2.png) [@hannahmac](https://community.dynatrace.com/u/hannahmac)\
**Post date:** [August 30, 2023, 9:13am UTC](https://community.dynatrace.com/t/how-to-add-an-xpath-locator-in-a-browser-clickpath-monitor-script/40063/4 "2023-08-30T09:13:11Z")

</div>

Could you add a javascript event and check if the resource loaded as expected?

```c-mrkdwn__pre
performance.getEntriesByName("<a class="c-link" href="https://mc.internal.dynatrace.com/opcon/fonts/bernina/BerninaSans-Web-Light.woff" target="_blank" rel="noopener noreferrer" data-stringify-link="https://mc.internal.dynatrace.com/opcon/fonts/bernina/BerninaSans-Web-Light.woff" data-sk="tooltip_parent">https://domain.com/fonts/bernina/BerninaSans-Web-Light.woff</a>")[0].responseStatus

```

response would be 0 if it hasn’t loaded.

---

<div class="post-metadata">

**Author:** ![daniel\_severino](https://avatars.discourse-cdn.com/v4/letter/d/b487fb/32.png) [@daniel\_severino](https://community.dynatrace.com/u/daniel_severino)\
**Post date:** [August 30, 2023, 11:42am UTC](https://community.dynatrace.com/t/how-to-add-an-xpath-locator-in-a-browser-clickpath-monitor-script/40063/5 "2023-08-30T11:42:04Z")

</div>

Thanks a lot!

You not only solved my question but also gave me ideas for other questions.

---

<div class="post-metadata">

**Author:** ![mborra2](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@mborra2](https://community.dynatrace.com/u/mborra2)\
**Post date:** [October 9, 2025, 10:33am UTC](https://community.dynatrace.com/t/how-to-add-an-xpath-locator-in-a-browser-clickpath-monitor-script/40063/6 "2025-10-09T10:33:20Z")

</div>

Hi team,

It looks like the design of the ticketing page has changed slightly which is causing an alert in Dynatrace. We have a synthetic script is flagging an issue with not being able to click on “XXX” but&nbsp; in the new design just shows “YYY” in a circle instead.&nbsp; How Can we adjust the test script for this?

Thanks,

B.Mahathi

---

<div class="post-metadata">

**Author:** ![hannahmac](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/hannahmac/32/41823_2.png) [@hannahmac](https://community.dynatrace.com/u/hannahmac)\
**Post date:** [October 9, 2025, 11:11am UTC](https://community.dynatrace.com/t/how-to-add-an-xpath-locator-in-a-browser-clickpath-monitor-script/40063/7 "2025-10-09T11:11:46Z")

</div>

You’ll need to update the script. If it’s just the locator that has changed, you can find it using the steps above and then update the relevant event. If the flow of the pages has changed, it may be easier to re-record the script.
