Kantu If condition is randomly failing

Hi,

I have below code in which it is first checking the condition as if button is present then it clicks that button and if it is not present then ideally it should skip the step.

  • Its working as expected sometimes but sometimes it is failing the test as that button is not present. ( ideally it should skip the step instead of failing the test case)

{
“Command”: “verifyElementPresent”,
“Target”: “id=identifierId”,
“Value”: “”
},
{
“Command”: “if_v2”,
“Target”: “${!LastCommandOK}”,
“Value”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//*[@id=“identifierNext”]/span”,
“Value”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”
}

is this the bug in kantu ?

You want to use ${!statusOK} == true not ${!LastCommandOK}

Many Thanks. Could you please share any example macro for this so that i will be more clear as where to replace it exactly.

Please confirm if below one is correct ?

{
“Command”: “verifyElementPresent”,
“Target”: “id=identifierId”,
“Value”: “”
},
{
“Command”: “if_v2”,
“Target”: “${!statusOK} == true”,
“Value”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//*[@id=“identifierNext”]/span”,
“Value”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”
}

Sure, I use this all the time to determine if I am already logged in or not by first looking for the login button when a macro is first accessing a website:

{
      "Command": "verifyElementPresent",
      "Target": "//button[text()='Login']",
      "Value": ""
    },
    {
      "Command": "if_v2",
      "Target": "${!statusOK} == true",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "id=login",
      "Value": "user@example.com"
    },
    {
      "Command": "type",
      "Target": "id=pswd",
      "Value": "__KANTU_ENCRYPTED__xxxxxxxxxxxx"
    },
    {
      "Command": "clickAndWait",
      "Target": "//button[text()='Login']",
      "Value": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": ""
    },