I would be gratteful if someone could give me some clue. I'm trying to dispatch Key up event in a input element after fill in it. Everything is in the Dom. The line code is in a loop. So it gives me something like this :
function makeSomeAction()
{
var arrayOfElementsNameToClick = [];
for( const Name of arrayOfNames){
myElementInput.value = Name;
myElementInput.dispatchEvent(new Event('keyup'));
var myResultOfSearch = document.querySelector("#blabla");
arrayOfElementsNameToClick.push(myResultOfSearch);
}
return arrayOfElementsNameToClick;
}
When i try this piece of code, it's working only for the last Name of arrayOfNames. I also tried to trigger the dispatch Event Element with an addEventListener. but it workking on the same way (last name of the array). It's like i should wait that the dom gives me some result to go to the next iteration of the for loop. The problem is that the dispatch event is not fired, and i can't access to the element of the search. Only the last element of my arrayOfNames.
What i expect is that the for loop
- load the right name on the input element,
- wait that the event has been dispatch on this element,
- and then takes the element from the dom with the usual querySelector and put it into an array
- after this only, it go throught the next iteration.
Here's a picture to illustrate my explanation:
I've already tried to addEventListener inside the loop without succeed. If someone could help me, i would be verry gratefull.

