Automatically insert assertions during recording?

I need to automate as much as possible the recording of Web test scenarios. Katalon Recorder plugin for Chrome seems very effective for this. However what’s missing in the recording are the assertions. I’ve so far found no real alternative than to “add them by hand” after the recording is done.

Now I know which parts of my pages contain relevant output text, i.e. are subject to test. For instance based on ID patterns, class names, tag hierarchy etc.

So given that my web app is in a “known good state”, I could theoretically grab the text content of the relevant tags during the recording, and insert my assertions in the recorded scenario right there and then. My aim is to automate this.

Is there any way to do this in Katalon Recorder? I’ve read about Katalon Extension Scripts but as far as I understand it, these cannot do what I want?

1 Like

For what it’s worth, I’ve managed to get what I needed by adding the following in source content/recorder.js, method Recorder.attach() :

var self = this;$(...).each(function(i, el) {
    var target = self.locatorBuilders.buildAll(el);
    if (el.tagName == "SELECT" || el.tagName == "INPUT")
        recorder.record("assertValue", target, el.value, false);
    else
        recorder.record("assertText", target, el.innerText, false);
});

(note ... are the JQuery selectors that define the areas that I know will contain relevant data in application. This could be tweaked either in this source (e.g. added more selectors), or in the application itself (e.g. adding a signaling class to certain tags just to trigger assertions).

While recording, assertions are now automatically added for the relevant parts (... in the above) of my web app, on each page load.

While this is perhaps rather crude, I think in itself this is a powerful feature, so I would love to see something similar added to the official functionalities of Katalon.

2 Likes

Thank you for the great discussion. We will work on the function in future releases.