on
12 Apr 2023
02:00 PM
- edited on
05 Mar 2026
03:45 PM
by
HannahM
querySelector call.var element = document.querySelector("#searchboxinput"); //Replace with the element which you want to perform the Location Dropdown
element.value = 'Waltham';
var event1 = new Event('input', { bubbles: true });
event1.simulated = true;
element.dispatchEvent(event1);
element.value sets the text in the input (e.g., Waltham).input event is dispatched so the application’s JavaScript thinks a real user typed the value, causing the autocomplete dropdown to appear.
var element = document.querySelector("#searchboxinput"); //Replace with the element which you want to perform the Location Dropdown
var evObj = document.createEvent('UIEvents');
evObj.initUIEvent('keydown', true, true, window, 1);
evObj.keyCode = 40;
setTimeout(function() { element.dispatchEvent(evObj); },1000);
evObj.initUIEvent('keydown', true, true, window, 1);
evObj.keyCode = 13;
setTimeout(function() { element.dispatchEvent(evObj); },2000);
keyCode = 40) to highlight the first autocomplete suggestion.keyCode = 13) to select that suggestion.setTimeout to give the page time to:
document.querySelector.element.value.setTimeout durations.input events (some frameworks might require change or other custom events too).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 provide a link to the monitor you're updating and the configuration steps you have already completed.
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).
// 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