jhonny
jhonny

Reputation: 858

Not Standard Input behavior?

I'm trying to automate something with a browser extension, and I'm facing a problem with an input.

The thing is, I can't set that specific input value to anything from the extension. If I do it manually from the console it works.
Setting the value does not work.
Using events does not work.
.click and .focus do not work, the value I set appears in the ui but the .value property is still "" and after a few seconds it disappears. I found a thread on reddit describing the same problem a year ago but it does not provide a solution.

Any idea of what else can I do?

Upvotes: -1

Views: 34

Answers (1)

jhonny
jhonny

Reputation: 858

I found the issue, my problem was https://github.com/RobinHerbots/Inputmask/releases/tag/4.0.6 onfocus event, for some reason while this listener is on the item I can't just change the value, the solution was simple but is weird an not intuitive

 input.dispatchEvent(new Event('input'));
 input.value = newValue;
 input.focus();
 input.dispatchEvent(new Event('input'));

Upvotes: 0

Related Questions