# How to perform Location dropdown(auto complete Address) with help of JavaScript Event on browser click path synthetic monitor.

**URL:** <https://community.dynatrace.com/t/how-to-perform-location-dropdown-auto-complete-address-with-help-of-javascript-event-on-browser-click-path-synthetic-monitor/39185>\
**Category:** Troubleshooting\
**Tags:** browser-monitors, synthetic-monitoring\
**Created:** [April 12, 2023, 1:00pm UTC](https://community.dynatrace.com/t/how-to-perform-location-dropdown-auto-complete-address-with-help-of-javascript-event-on-browser-click-path-synthetic-monitor/39185 "2023-04-12T13:00:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mareeswaran](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@Mareeswaran](https://community.dynatrace.com/u/Mareeswaran)\
**Post date:** [April 12, 2023, 1:00pm UTC](https://community.dynatrace.com/t/how-to-perform-location-dropdown-auto-complete-address-with-help-of-javascript-event-on-browser-click-path-synthetic-monitor/39185/1 "2023-04-12T13:00:00Z")

</div>

## Summary

If your web application uses autocomplete, for example, a&nbsp; **location autocomplete** field, like an address search box backed by Google Maps or similar), the standard synthetic recording may not reliably capture the interaction.In these cases, you can use **JavaScript events** inside a **browser clickpath monitor** to:

1. Type a value into the location search field.
2. Trigger the autocomplete dropdown.
3. Select a location from the dropdown using simulated key events.

Below is a step‑by‑step guide.

## Steps to handle an autocomplete dropdown

### Locate the autocomplete input element in Chrome

1. Open **Chrome** and navigate to the page that contains the **location/address autocomplete** field.

2. Right‑click on the input field you want the synthetic monitor to interact with.

3. Select **Inspect** to open **Chrome DevTools** on that element.

### Copy the JS path (or a suitable selector) for the input

1. In **Chrome DevTools** , ensure the correct element is selected in the **Elements** panel.

2. Right‑click that element in the DOM tree.

3. Choose **Copy → Copy JS path** (or copy a stable CSS selector, if preferred).

 ![image2.png](https://global.discourse-cdn.com/dynatrace/original/2X/c/c8d3be690f56abe749ea0b66356916f4e2c197b0.png)

### JavaScript event 1 – Enter text and trigger the autocomplete dropdown

1. Create a **JavaScript Event** step in your **browser clickpath synthetic monitor** and paste the selector you copied into the `querySelector` call.

### JavaScript event 2 – Select the first location result from the dropdown

1. Add another **JavaScript Event** step in the same **browser clickpath monitor**. Use the same selector to target the input element and then simulate key presses to select an option from the dropdown.

## What’s Next

### Practical tips and troubleshooting

- **Selector stability** : If the JS path is too fragile (e.g., dynamic IDs), consider using a more stable selector (like a CSS selector based on class/attributes) when calling `document.querySelector`.
- **Multiple locations** : For different test locations, duplicate the same JavaScript event and just change `element.value`.
- **Timing issues** : If the dropdown doesn’t open or the wrong item is selected:
  - Increase the `setTimeout` durations.
  - Confirm that the location field responds to `input` events (some frameworks might require `change` or other custom events too).

- **Validation** : Use screenshots and step‑level validation in the browser monitor to confirm the correct location is selected.

### Create a Support ticket/ chat

If the browser clickpath monitor isn’t able to select the location using the steps in this guide, along with the troubleshooting tips, please open a chat, or create a support ticket and&nbsp;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/shortlink/browser-monitors-config)

📖&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:** [May 12, 2023, 6:50pm UTC](https://community.dynatrace.com/t/how-to-perform-location-dropdown-auto-complete-address-with-help-of-javascript-event-on-browser-click-path-synthetic-monitor/39185/2 "2023-05-12T18:50:11Z")

</div>

Thank you for sharing this

---

<div class="post-metadata">

**Author:** ![ToWo](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@ToWo](https://community.dynatrace.com/u/ToWo)\
**Post date:** [March 5, 2026, 3:02pm UTC](https://community.dynatrace.com/t/how-to-perform-location-dropdown-auto-complete-address-with-help-of-javascript-event-on-browser-click-path-synthetic-monitor/39185/3 "2026-03-05T15:02:14Z")

</div>

Hello,

many thanks for sharing this. For me it was necessary to change step 2 to the following:

In addition I need a wait for 2 seconds for next step between step 1 (enter Location) and step 2 (select from maps response).

```javascript
// Keydown Arrow Down nach 1 Sekunde

var element = document.querySelector("#input_YOUR_Selector");

setTimeout(() => {
    const ev1 = new KeyboardEvent('keydown', {
        bubbles: true,
        cancelable: true,
        key: 'ArrowDown',
        code: 'ArrowDown',
        keyCode: 40, // einige Browser nutzen das noch
        which: 40
    });
    element.dispatchEvent(ev1);
}, 1000);

// Keydown Enter nach 2 Sekunden
setTimeout(() => {
    const ev2 = new KeyboardEvent('keydown', {
        bubbles: true,
        cancelable: true,
        key: 'Enter',
        code: 'Enter',
        keyCode: 13,
        which: 13
    });
    element.dispatchEvent(ev2);
}, 2000);

```

Cheers,

Tom

---

<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:** [March 5, 2026, 3:09pm UTC](https://community.dynatrace.com/t/how-to-perform-location-dropdown-auto-complete-address-with-help-of-javascript-event-on-browser-click-path-synthetic-monitor/39185/4 "2026-03-05T15:09:22Z")

</div>

Thanks Tom, that’s really helpful.
