Labels for error handling inside while loop?

Hello,

So I have a script where I loop through a csv file which contain many accounts login information. I use those to login to a site then write data to another csv file. The issue is if the login doesnt work or if there is another error, I still want to write to the csv (but with a specific error) then continue to the next account.

However, the commands under the “error” label are always read by the script. How do I isolate them so they are only read when theres an error and the the loop continue as usual?

My script goes something like this:

 "Commands": [
    {
      "Command": "csvRead",
      "Target": "accounts.csv",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "while_v2",
      "Target": "${!csvReadStatus} == \"OK\"",
      "Value": "",
      "Description": ""
    },

Then I do some stuff and verify if an element is present, if it is I want to go into my “error handling” label “cannotLogin” and it works fine but the issue is that if the error is not present the commands under the label “cannotLogin” still run.

    {
      "Command": "verifyElementPresent",
      "Target": "id=errorList",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "gotoIf_v2",
      "Target": "${!statusOK}",
      "Value": "cannotLogin",
      "Description": ""
    },

Its probably easier with screenshot so heres the whole thing. Im new at this so Im probably missing something obvious but the question is how do I handle a different error path inside a while loop so the commands under that label are only ran when theres is an error and the loop continues afterwhich.

Thank you

hi, the issue sounds somewhat similar to the how to mark a CSV line as processed question
=> In your case you would need to mark the logins that do not work, so you can retry them later, or?

You do that by putting the error handling block (lines 39-50 by the looks of it) inside an if statement with the condition as “false” so that it never gets executed without an error sending the macro to your “cannotLogin” label

It looks like 35-38 and 47-50 is repeated code that you want executed regardless of errors, so I’d delete 35-38 and put 39-46 inside the if false block, that way 47-50 will get executed each loop even when there’s an error