If Condition not work


#1

Hi.

I use Katalon recorder


Why this not work?

if 3<2 {
echo bad
}
else
{
echo good
}

return:
bad
good

image.png


#2

OMG. I see what happened. how to check ${string} == ${string} ?. This return value in ${string} is not defined


#3

Hi,

first you have to create variable named “string” to be able to compare that to something, use one of the command which start with “store”. If you want to compare strings you can use store command to create one - it will be string value in the Variables tab, for number use storeEval. If you want to take text from page use “storeText” command and then you can compare almost like you wrote it, so it would be like:

“${string}” == “${string2}”

in target of “if” command.

If you want to compare numbers/strings like on your screenshot so it’s not a variables dependend on website content it looks like it have no sense because it will always give same result.