To simulate a CLICK event, you must first send:
element.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_DOWN, true, false));
and then:
element.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_UP, true, false));
In the MOUSE_UP event, the handler then throws a click event (if the mouse is on top of the element, so you may need to set the mouse_x and mouse_y variables in the dispatched event.
source
share