Missed events in Chrome

Hi,
I noticed that some click events were reproducibly never caught by Katalon Recorder (3.5.5.0 but similar with Katalon Studio latest). I didn’t immediately find why, or in what exact circumstances (most click events were captured, only very few weren’t).
I’ve seen many different complaints/queries in the Katalon discussion fora, most without a definitive answer.
I’ve been debugging the Recorder code quite a lot and it turned out the event was simply not delivered to Katalon by Chrome. So searching instead for a Chrome related issue, I found these articles:

Connecting the dots, I was able to solve the issue in Katalon Recorder, by adding the following code at the start of Recorder.addEventHandler in recorder.js:

if (eventName == "mousedown") {
  Recorder.addEventHandler(handlerName, "pointerdown", handler, options);
  Recorder.addEventHandler(handlerName, "touchstart", handler, options);
} else if (eventName == "mousemove") {
  Recorder.addEventHandler(handlerName, "pointermove", handler, options);
  Recorder.addEventHandler(handlerName, "touchmove", handler, options);
} else if (eventName == "mouseup") {
  Recorder.addEventHandler(handlerName, "pointerup", handler, options);
  Recorder.addEventHandler(handlerName, "touchend", handler, options);
} else if (eventName == "click") {
  Recorder.addEventHandler(handlerName, "tap", handler, options);
}

It would be great if you could verify this and incorporate this in your official releases, or suggest a different approach.
Best regards
Geert

2 Likes

The following additional changes were needed, in recorder-handlers.js:

  • in Recorder.addEventHandler(‘dragAndDrop’, ‘mouseup’, function(event)

right after the declaration of var x and y:

        if (x == 0 && y == 0) {
        	console.log("Redirecting to click");
        	this.record("click", this.locatorBuilders.buildAll(event.target), '');
        	return;
        }

Apparantly only mouseup/mousedown are received in these special cases, so the above change makes a combination of both event with zero movement in between translate into a click event.

  • in Recorder.addEventHandler(‘dragAndDrop’, ‘mousedown’, function(event)

removed the setTimeout on the setting of selectMousedown.

//        this.selectMouseup = setTimeout(function() {
            self.selectMousedown = event;
//        }.bind(this), 200);

Otherwise the mousedown coordinates are not known yet when the mouseup happens, on fast clicks, leading to apparent non-zero movement in the first block.

2 Likes

hi,
ii checked when the button is tap event , it click failed on katalon mobile emulator.
can you share a case how to use those code,thanks
forgive my poor code ability .