Set Text trigger twice onchange event

Set Text trigger twice onchange event in browser input field, first when clear field and second when insert text.
Onchange should be triggered only once, after text insert to field.

Something definitely odd happening with the forum listing – another old/unanswered post surfacing to the top of the list…

caveat emptor: I have not reviewed the WebUI.setText source.

Given the specification for how setText is said to work, this would seem to be correct behavior. “Set the value of an input field, as though you type it in. It also clears the previous value of the input field.” (https://docs.katalon.com/katalon-studio/docs/webui-set-text.html). So that’s two changes: one to clear the field and another to set the new value.

However, from an automation perspective, that is wrong and should be fixed. Automation is meant to mimic closely what a user would do. Clearing the field and setting a new value would not (under normal circumstances) cause two events to fire since a user would not cause the field to lose focus during this two-step process. Plus, according to the change event specification, the event should not fire until the field loses focus:

You can read about change/onchange at MDN (the linkage to the HTML spec does not go directly to anything useful). https://developer.mozilla.org/en-US/docs/Web/Events/change

Caveat: There are reports of IE doing something strange with select elements, calling onchange when keys are pressed but I’ll defer heading into that quagmire here. :sunglasses:

@devalex88 has edited a couple of old topics, which pops them to the top.

Yeah, sorry for that. I’m putting forgotten ones to the right place (mainly those in Tips and Feature Requests).

That’s why I moved this to Bug Reports, and it got bumped.

1 Like