Recommendation: Supporting re-usable code snippets (aka. functions / classes)

Hello

I realise that we already have for / while loops, and we can use CSV files to help loop through a series of steps, but there is one area that seems to only be in the realms of say Katalon Studio (or other similar solutions), and that is having the equivalent of functions or classes, that can be called from a KAR script.

Whilst there are ways one could achieve this without introducing functions (using conditional checks it already does support), the potential layers of logic then required just to implement something like this could end up quite nested / messy.

KAR already has a related bit of functionality (Global Variables), which can be referenced from a script, but if this idea could be extended to not just cover a single step, but a selection of steps, this could potentially mean that generating new scripts to cover new use cases could become as easy as more complex scripting languages / traditional programming languages (e.g. as you could create a library of ‘functions’ that can then be ‘dropped’ in and used where relevant).

This means that KAR will offer one of the key advantages of these other languages for automation, whilst reducing code (script) duplication, improving maintenance efforts, and depends on how it is executed, potentially reducing execution time too.

Given the Action | Parameters / Target | Value syntax for scripts, this could be called using something like this:
Action: runFunction
Parameter / Target: GlobalFunction.UploadMedia
Value: ${filename} ← To allow passing a value to the function

KAR has already proven it can offer features that people are otherwise forced to alternative more complex offerings for, so I am hopeful that this is possible too.

2 Likes

Hi @guy.mason,

Thank you for sharing this with our community. This should be an interesting topic for our product team. Let me talk to them and share the feedback then. Cheers!

1 Like

Thanks @vu.tran, that would be appreciated :slightly_smiling_face:

In addition to Global Variables, Dynamic Test Suites is another example of KAR elevating itself beyond a ‘simple’ Selenese browser-based tool, and becoming a more sophisticated automation tool, so this idea still very much aligns with what KAR is otherwise doing there.

1 Like

Hi @guy.mason,

Thank you for your patience. We talked to our internal product team. As of now, they encourage users to use our Katalon Studio (free version) for this feature. Hope this clarifies your concern. If there is any change in the future, we will announce to all users via our release note. Thanks again for your contribution.

@vu.tran I suspected that this might be the response. This has long been an option too. But, for people deliberately making the choice not to use Katalon Studio (e.g. as it generally then involves moving beyond Selenese-based scripting to more ‘traditional’ programming and scripting languages), then this limits how powerful a tool KAR can be in this sense, and limits what options people have when using this tool alone.

I’d like to hear @ThanhTo’s response to this idea.

2 Likes

Hi @guy.mason

Thanks for the very detailed recommendation :grinning:. I remember this recommendation from our last conversation as well. Right now we’re re-directing our efforts into platform initiatives, so right now we temporarily are holding off on Katalon Recorder (you may notice from the slow release cadence after 5.9.0 - we tried to make the UX pleasant before holding off - if there’s any feedback for it’d be greatly appreciated).

But anyway, I fully understand the recommendation, we will be sure to look into it once we resume. Thank you for the support.

4 Likes

Hey @ThanhTo

Yeah, I realise that I brought up the general concept when we had that chat, but you have since then added features such as Global Variables and Dynamic Test Suites (amongst other things), so these kinds of ideas are all advancing towards the same goal (with what I’ve suggested here).

Thanks for updating us on the behind the scenes project planning and scheduling happening there, that definitely is appreciated!

Regarding UX, generally speaking it is nicely designed. When I encountered the issues with Global Variables (https://forum.katalon.com/t/bug-with-global-variables-in-5-9-0/), it did make me wonder if there was a way to make it more apparent from the script view if a profile had or hadn’t yet been assigned to a particular script.

The presence of Global Variables in the Variables tab would normally be a good indication that these had been assigned, but when this issue happened (after adding in new variables via the profile to use with a script and then attempting to use it in the related script), I was left uncertain what was the case there, as only the pre-existing global variables showed up. .

Not UX issues, but there is also this bug with the UI (at the right viewport sizes anyhow)

Plus, the issue i’ve mentioned in other threads where it almost always hangs the extension a few times before finally loading all the scripts. It never used to happen, but since the revamp of the script view (e.g. the in-line text elements) it started happening.

The bugs impact the UX, but are not due to UX-related designs you’ve implemented!

2 Likes

Side note, tried a workaround to this, using labels and gotoLabel, but when I use it, it does go to the label, but at the point I then direct it to return to the variable-defined label I specified (e.g. go back to just after the line where it had come from before going to the label), it then starts skipping all the following commands (e.g. just highlighting them as green, but not executing any of them).