I'm using the Kantu web automation tool for the first time. Most of it is intuitive, but I'm now encountering an error when looping through a CSV. The relevant part of my script is:
{
"Command": "echo",
"Target": "Found customer with email ${emailAddress}",
"Value": ""
},
{
"Command": "echo",
"Target": "Expected email name: ${!COL1}",
"Value": ""
},
{
"Command": "if",
"Target": "${emailAddress} == \"${!COL1}@domain.com\"",
"Value": ""
},
This produces the following log:
[info] Executing: | echo | Found customer with email ${emailAddress} | |
[echo] Found customer with email 70866223@domain.com
[info] Executing: | echo | Expected email name: ${!COL1} | |
[echo] Expected email name: 70866223
[info] Executing: | if | ${emailAddress} == "${!COL1}@domain.com" | |
[error] Error in runEval condition of if: Invalid or unexpected token
So you can see the variables ${emailAddress}
and ${!COL1}
are stored correctly, but my if
condition is not evaluating correctly. I've also tried changing \"${!COL1}@domain.com\"
to ${!COL1} + \"@domain.com\"
with same result.
I assume this is something to do with escape characters or something, but I can't find anything related in the docs. Any pointers appreciated.
The if expression is handled like in storeEval. To quote from one of the storeEval examples in the docs :
x="${myvar}"; x.length;
Note that our variable ${myvar} is converted to a text string before the Javascript EVAL is executed. Therefore ${myvar} has to be inside "..." like any other text.
So I'd say the reason your code fails on the if is that your ${emailAddress} is not inside a String.
"${emailAddress}" == "${!COL1}@domain.com"
should work.