Perfect Data Binding Workaround / Work With Any Data Type Easily

MY INFO
Windows 10 21H1 64-bit
Katalon Studio 8.0.5.208

Hi,
I have a serious problem with Katalon Studio, that it binds all Variables to Test Cases as String and totally ignores selected Data Types. This appears to be true whether or not the “Bind to test case as String” checkbox is selected on the data file. I found other guys here on Forum or elsewhere on the Internet that said, that they couldn’t make it work neither, so I am convinced this isn’t actually working for anybody. But it is a serious problem, because at least boolean (to parametrize checkboxes for example), numbers and lists should really be working. Maybe even custom Data Types would be of use. But sadly, everything is just a string and it is painful to manually parse everything from String.

This is very weak point of Katalon Studio, so I believe you should highly PRIORITIZE IT :slight_smile:
Pleeeeease :pray: :pray: :pray: :grinning:

But I created awesome workaround myself, which allows to work with any data types easily.
I had an idea, to use Description column in Test Case Variables tab for writing your desired data type like this:
87d0bad6a246bc2aa7f5a6a8295c0b6c376d6545
** Note, that I set all Types to String in Type column

Supported data types are:
String, Bool, Char, Byte, Short, Int, Long, Float, Double, LocalDate, LocalTime, LocalDateTime, ZonedDateTime, Period, Duration, List, Map and CustomData

There are only 2 things that needs to be done at the beginning of a project to make this work:

  1. Create package “Utils” in Keywords and place Data.groovy Data.zip (2.4 KB) file under it:
  2. Add this method to TestListener:

    ** Note that this method will run only if you run whole TestSuite. If you run only single TestCase, this method won’t run, so data parsing won’t work.

And that’s it! This will automatically parse all your variables to desired data types and you can use them normally.

Now, if you want to use your own Custom Data Type, you can either implement ICustomTestData interface to provide your parsing logic, or just extend JsonTestData class to make it automatically parse using JSON.

1 Like

Now there are still few problems that persist even after creating this solution:

  1. My solution will be used only by people that discovers this, not by everyone => That’s why it should be made official.

  2. It would be much better to use Data Type in that Type column instead of Description column so everybody sees what data types can be chosen with that SelectBox (it could also look for your custom data types).
    And of course, there would be no mistyping like now can happen easily in Description column.

  3. Because all values is just a string that needs to be parsed, it’s hard to create these actual values. For example, when you want to write DateTime, you now don’t really know, what date format should be used. Or if you want custom data type, you have to write it like JSON. So when using Internal Data like a data source, there should be support tool for creating those values (like when doing Lists for example). You could just select year, month and day somewhere when Date is your data type and you wouldn’t have to worry about correct format.

  4. And it would of course allow validation of all data that will be used in Tests ( wheter they are in correct format and can be parsed without any problem). And it could run separately from Tests, like before all tests even run. So no tests would never fail because of problem with data parsing, because all problems would be known beforehand.

1 Like

Hi Peter,

Thank you for the contribution, we will have a look into this

1 Like

@peter.hevesi Thank you for this great solution! I stumbled upon this while writing my own, although if possible can you please provide a sample csv or excel sheet with maps & list in them?

1 Like

Hi,
Sorry I have not replied for a long time, but I haven’t noticed your post.
I created it in the way, in which you write lists and maps in json format, so list would be like this:
[“item_1”, “item_2”, “item_3”]

And map would be like this:
[ “key_1” : “value_1”, “key_2” : “value_2”]

I have then created even a solution, where you don’t have to write your custom data in JSON, but you can put ID in some of your custom data and then reference it. To illustrate this, let’s say I need to create array of 2 people, so let’s say I have my own class Person, which has ID property, and I have 2 persons with ids “BillGates” and “SatyaNadella”, then I could make a list of them and reference it by this ID by using # symbol.
So I would have: ["#BillGates", “#SatyaNadella”] and this is list of my custom objects I have in different excel, so I don’ need to write them in JSON format.

And I then even solved the problem, that now, those data parses into correct data type, but they are not casted to correct data type. When you go to see that variables, you see them as objects. So I have even created a Powershell script outside of Katalon Studio, which goes through a variables for every test and then creates classes, that cast these objects to the desired data type.
So I then have this line of code at the beggining of a test:
CastedTestData data = CastedTestData.createFrom(this)
And then I am able to write data.SomeVariable inside a test, and that SomeVariable is already in correct data type :slight_smile:

So both of these 2 improvement worked very fine for me, but I haven’t uploaded these yet, because I am not using Katalon Studio anymore.
I found Microsoft Playwright, which is waaaay better Testing Tool than Katalon Studio.
It is new, it is TOTALLY FREE & OPEN SOURCE, still developing rapidly, ported to many programming languages (C#, Java, Python…) but it also have recorder for those, who can’t code. And it is actually much more reliable, faster, better in like everything.

So to anybody who comes to read this post, I absolutely don’t recommend to use my solution anymore, not because it doesn’t elegantly solves this lack of proper types support for test variables in Katalon Studio, but because I absolutely don’t recommend using Katalon Studio to anybody anymore :smiley:
Using Microsoft Playwright, you can have much better control of Test Data Variables :smiley:
This need for workaround like mine is very huge weakness of Katalon Studio. And it has many other weaknesses I experienced while using it :smiley: It is often laggy, whole IDE is based on Eclipse, which is waaay inferior to Visual Studio, which I am using with that Playwright (I use .NET version of Playwright with C# :slight_smile: ) It uses Selenium, which is waaay inferior to Playwright.
My opinion is, that all testing tools, which uses Selenium aren’t good, because Selenium isn’t reliable :smiley:

Microsoft Playwright is the future of Test Automation for Web, I have no doubts ! :smiley:
But It would be awesome, if you could test native apps (iOS, Android or Windows) with Playwright as well, which it is not possible yet. So to test native apps, you still need to use Appium.