Test for Undefined Variable


#1

Fairly new to Kantu/Selenium and I can’t seem to figure how to test if a variable is blank.

All I want to do is check if the DueDate is blank. And if it’s blank, I will assign today’s date (I will replace the echo DueDate is Blank with the assignment). If the DueDate is blank, I’m getting the following error (it’s like the variable doesn’t exist):

Executing:  | if | ${myPendingDate} == "" |  | 
[error] Error in runEval condition of if: Unexpected token ==

Here’s the code I have

{
  "CreationDate": "2018-11-25",
  "Commands": [
    {
      "Command": "storeValue",
      "Target": "id=DueDate",
      "Value": "myDueDate"
    },
    {
      "Command": "if",
      "Target": "${myDueDate} == \"\"",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "DueDate is Blank",
      "Value": ""
    },
    {
      "Command": "endif",
      "Target": "",
      "Value": ""
    }
  ]
}

I’m sure there’s a simple way to do this. Thanks in advance.


#2

It’s almost correct, but you need to put the variable in “”:

if |"${myPendingDate}" == “”


#3

Thanks. I thought I tried that as well but obviously didn’t. Works now!