Kantu if 条件中的无效或意外标记

Invalid or unexpected token in Kantu if condition

我是第一次使用 Kantu web automation tool。其中大部分是直观的,但我现在在循环 CSV 时遇到错误。我脚本的相关部分是:

{
  "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": ""
},

这会产生以下日志:

[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

因此您可以看到变量 ${emailAddress}${!COL1} 已正确存储,但我的 if 条件未正确评估。我也试过将 \"${!COL1}@domain.com\" 更改为 ${!COL1} + \"@domain.com\",结果相同。

我认为这与转义字符或其他东西有关,但我在文档中找不到任何相关内容。任何指点表示赞赏。

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.

所以我想说您的代码在 if 上失败的原因是您的 ${emailAddress} 不在字符串中。

"${emailAddress}" == "${!COL1}@domain.com"

应该可以。