How to use stored variables

Hey everyone, longtime Selenium IDE user but first time Katalon user. I am using the Katalon IDE to run some already existing Selenium IDE test cases but the variables don’t seem to be working the same. I am able to store the variables but when I try to use them it prints out the variable format and not the actual stored variable. I looked around online and all the examples I have seen seem to use the same ${foobar} format.

In my screenshot the log shows that the variables are stored. Any help would be great! Thanks!

katalon example.JPG

You need to run a full test! It’s not working with manual executing commands…

Yup that solved it, Thanks!

However, one of the things I loved about Selenium IDE is that if the test stopped for some reason you could start it up again where it left off and it would retain the variables. Is that not possible yet with Katalon? Will it be?

Recently started using Katalon Recorder and miss the ability to have the variables remain and edit them until I cleared one, several, all, or closed the app.

If I declare a variable in one test case to use in any other test case I have to run the entire suite as it works now which is a pain.

Maybe I haven’t stumbled on a way yet in the discussion forums to work around this but it would be nice to have those features.

1 Like

I was just checking in on this after not being here in a long time. I want to make the full transition to Katalon however this is is a pretty big roadblock for me. If the test fails and I could start it up again at the point of failure while retaining the variables that would be amazing.

3 Likes

Checking in again if there is any workaround to keep the stored variables after stopping and resuming the test. This is a must have for the kind of test I do. This is the only thing that’s keeping me from using Katalon. Still using old firefox and old IDE!

1 Like

I have taken to storing the variables in session storage and pulling them back when I need them.

  • runScript | sessionStorage.setItem(“baseURL”, prompt(“Enter baseURL.”)); | baseURL will store the varialble

  • The following will retrieve the variable when needed - runScript | return sessionStorage.getItem(“baseURL”); | baseURL .

I am thinking I got this from someone on this forum.

It’s great idea, for my test I’m using localStorage instead. The only difference between localStorage and sessionStorage is that data in sessionStorage will be deleted after session is closed i.e. closing the browser.

Dennis_Hohn You can add this solution to https://forum.katalon.com/c/katalon-recorder/tips-and-tricks

And little tip from me: if you have a lot of data to store you can use object in JavaScript. It works like this:

  1. Create object with your data like this:

var person = {name:“John”, lastName:“Smith”, age:28};

Whit Katalon variables it will be like this:

var person = {name:"${personName}", lastName:"${personLastName}", age:${personAge}};

  1. Then when you want to save it, use:

var newvar = JSON.stringify(person); // It convert object to string
sessionStorage.setItem(“myData”, newvar); // It saves string newvar in sessionStorage using myData as key

Now when you Inspect Element on page and go to “Application” tab on the left, under “Storage” open “Session Storage” and there will be your data displayed in elegant way.

  1. When you want to take the data back to Katalon use:

var localData = sessionStorage.getItem(“myData”); //It takes data from sessionStorage to localData var
var parsedData = JSON.parse(localData); // It change data from string to object

and to get one of the fields use:

var personName = parsedData.name;

To return this data use trick from: Katalon Automation Recorder - Tips and tricks point 6 because you need to return variables one by one.

1 Like

Hello.

Is it possible downgrade the Katalon Recorder version?

I got the version 5.5.4.3 for Chrome and 5.5.3 for Firefox.

I am using runscript | return(Math.floor(Math.random()*1000)) | random
and then I ran type | id=fieldID | ${random} for years.

Apparently, the second command is returning ${random} instead of the value.

Today it works only in Firefox for me. It can be the problem with the version or Chrome.

I would like to know if it possible to downgrade the version of Katalon Recorder in Chrome.

Hi @svetadavidson

Can you provide us with a sample test case to reproduce? It seems to run fine on my side

If there’s a truly a problem, we do have earlier releases available here, you can install them in your Chrome browser with this guide