I'm writing tests using CasperJS for legacy GWT (2.3) code.
I can change the selected value of a ListBox.
document.querySelector('#id_of_select').selectedIndex = 1;
But this does not trigger the onChange() method of a change handler on the ListBox.
I have tried manually dispatching a change event on the select element (jquery is not available on the page):
var evt = document.createEvent("manualchange");
evt.initEvent("change", false, true);
document.querySelector('#id_of_select').dispatchEvent(evt);
I've also tried it this way.
document.querySelector('#id_of_select').dispatchEvent(new Event('change', { 'bubbles': true }));
Neither approach triggers the onChange method of the change handler. Can anyone suggest a way to get this working?