"[bug] [issue #410] Cannot read property 'index' of undefined" when executing "else" command


#1

Hello.
Chromium 68 on linux mint 18.2
Kantu 3.1.2

I am getting an error for element not present, and get an error for “else” command:
[error] Cannot read property ‘index’ of undefined


FF 61.0.1 with kantu 3.1.3 says other error here:
[error] tag.fork is undefined

Any ideas what causes it and how to handle it?


#2

Hi, I did a quick test, and the “DemoIfElse” macro works fine.

So does this “only” happen in this macro? And if so, can you please paste the macro JSON source code here for me to test?


#3

I’m seeing the same error on Chrome 68 on Windows 10 and Kantu 3.1.2.


#4

JSON of my macro that 100% reproduces the problem. Email and password have been scrubbed. The error happens on the ‘else’ clause around line 90.

{
  "CreationDate": "2018-8-10",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://www.heb.com/my-account/login?DPSLogout=true",
      "Value": ""
    },
    {
      "Command": "verifyElementPresent",
      "Target": "link=Log Out",
      "Value": ""
    },
    {
      "Command": "if",
      "Target": "${!LastCommandOK}",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "link=Log Out",
      "Value": ""
    },
    {
      "Command": "endif",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "open",
      "Target": "https://www.heb.com/my-account/login/",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "id=login-email",
      "Value": "example@email.com"
    },
    {
      "Command": "type",
      "Target": "id=reg-password",
      "Value": "ExamplePassword"
    },
    {
      "Command": "clickAndWait",
      "Target": "id=login-submit",
      "Value": ""
    },
    {
      "Command": "label",
      "Target": "SELECTION_LOOP",
      "Value": ""
    },
    {
      "Command": "open",
      "Target": "https://www.heb.com/digital-coupon/coupon-selection/",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "0",
      "Value": "couponCount"
    },
    {
      "Command": "while",
      "Target": "(${couponCount} < 30)",
      "Value": ""
    },
    {
      "Command": "assertElementPresent",
      "Target": "link=Select Coupon",
      "Value": ""
    },
    {
      "Command": "if",
      "Target": "${!LastCommandOK}",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "link=Select Coupon",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "Selected coupon",
      "Value": ""
    },
    {
      "Command": "else",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "All coupons claimed. Exiting",
      "Value": ""
    },
    {
      "Command": "endif",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "storeEval",
      "Target": "${couponCount}+1",
      "Value": "couponCount"
    },
    {
      "Command": "endWhile",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "gotoLabel",
      "Target": "SELECTION_LOOP",
      "Value": ""
    }
  ]
}

#5

Thanks… the problem is that we can not run this macro. Does anyone see the same issue with a macro on a public website that she or he can share?

I first thought that having if / else / endif inside a while loop causes the issue since that is something that the macros from both of you have in common. But the test macro I made with it worked fine, too. :thinking:


#6

That heb.com website is a public site, for what it’s worth. It’s just a grocery store chain in Texas. If you create a free account and put the login credentials in the script above, there’s no reason you couldn’t run this script. Anyway, thanks for looking into this. :slight_smile:


#7

Seems my macro suits Kantu example table.
I changed link, macro goes with the error, @admin please check:

MACRO

{
“CreationDate”: “2018-8-13”,
“Commands”: [
{
“Command”: “open”,
“Target”: “https://a9t9.com/kantu/demo/csvsave”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “2”,
“Value”: “!timeout_wait”
},
{
“Command”: “store”,
“Target”: “1”,
“Value”: “GLOBAL_counter”
},
{
“Command”: “store”,
“Target”: “Montant global approximatif”,
“Value”: “GLOBAL_searched_text”
},
{
“Command”: “store”,
“Target”: “1”,
“Value”: “GLOBAL_page”
},
{
“Command”: “store”,
“Target”: “false”,
“Value”: “GLOBAL_found”
},
{
“Command”: “while”,
“Target”: “${global_found} == false”,
“Value”: “”
},
{
“Command”: “storeEval”,
“Target”: “${GLOBAL_counter}+1”,
“Value”: “GLOBAL_counter”
},
{
“Command”: “store”,
“Target”: “true”,
“Value”: “!errorignore”
},
{
“Command”: “click”,
“Target”: “//tr[${GLOBAL_counter}]”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “false”,
“Value”: “!errorignore”
},
{
“Command”: “if”,
“Target”: “${!statusOK} == false”,
“Value”: “”
},
{
“Command”: “storeEval”,
“Target”: “${GLOBAL_page}+1”,
“Value”: “GLOBAL_page”
},
{
“Command”: “store”,
“Target”: “1”,
“Value”: “GLOBAL_counter”
},
{
“Command”: “click”,
“Target”: “link=${GLOBAL_page}”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “true”,
“Value”: “!statusOK”
},
{
“Command”: “click”,
“Target”: “//tr[${GLOBAL_counter}]”,
“Value”: “”
},
{
“Command”: “endif”,
“Target”: “”,
“Value”: “”
},
{
“Command”: “verifyElementPresent”,
“Target”: “//div[@class = ‘info-table’]/div[contains(., ‘${GLOBAL_searched_text}’)]”,
“Value”: “”
},
{
“Command”: “if”,
“Target”: “${!statusOK} == false”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “true”,
“Value”: “!statusOK”
},
{
“Command”: “store”,
“Target”: “false”,
“Value”: “!errorignore”
},
{
“Command”: “else”,
“Target”: “”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “true”,
“Value”: “GLOBAL_found”
},
{
“Command”: “endif”,
“Target”: “”,
“Value”: “”
},
{
“Command”: “endWhile”,
“Target”: “”,
“Value”: “”
}
]
}


#8

I also get the same error when using an if then else command, as specified in the example.
The error message I see is:

“[error] tag.fork is undefined”

which occurs on the else statement. I’m using Firefox 63.0 64 bit - i tried with Kantu Browser Automation 3.1.2, then i updated to V3.3.3 just now, and still get the same error.


#9

Same here. Mentioned that in other thread.


#10

thanks for the bug reports… I just want to mention that I created a ticket for it, and we will be fixing this asap.


#11

I’m having the same problem.
As a workaround I’m using another IF statement instead of using ELSE (which seems to be the problem).


#12

@LucasC I marked your answer as temporary solution, thanks for the hint. Of course the bug itself remains open and will be fixed asap.