In while csvread, force macro to read new line after a specific task timeout/fail?

Hello,

I’ve got a while loop that reads a csv and then does several steps. Currently, if i have the errorignore set to True, it goes through every step before moving to the next csv line, which takes a long time.

I’d like to force reading an entirely new line if a particular step fails, rather than just timing out after each failed step. Alternatively, if errorignore is set to False, the entire macro stops. Ultimately, I’d like to be able to tell the program to move to the next row/line in csv when I want it to, after a specific task fails.

Thank you for your feedback. Here is my code:

{
“Name”: “DemoCsvReadWithLoop_turnoffupdate_new”,
“CreationDate”: “2019-3-19”,
“Commands”: [
{
“Command”: “store”,
“Target”: “fast”,
“Value”: “!replayspeed”
},
{
“Command”: “csvRead”,
“Target”: “loopingtues1.csv”,
“Value”: “”
},
{
“Command”: “while”,
“Target”: “”{!csvReadStatus}\" == \"OK\"", "Value": "" }, { "Command": "store", "Target": "true", "Value": "!errorIgnore" }, { "Command": "echo", "Target": "Status = {!csvReadStatus}, line = {!csvReadLineNumber}", "Value": "" }, { "Command": "open", "Target": "{!COL1}",
“Value”: “”
},
{
“Command”: “comment”,
“Target”: “”,
“Value”: “has opened the administrator backend”
},
{
“Command”: “type”,
“Target”: “name=rsf_backend_password”,
“Value”: “{!COL2}" }, { "Command": "clickAndWait", "Target": "/html/body/div[1]/form/button", "Value": "" }, { "Command": "comment", "Target": "", "Value": "submit button from rsfirewall, next step goes into main login" }, { "Command": "type", "Target": "id=mod-login-username", "Value": "{!COL3}”
},
{
“Command”: “type”,
“Target”: “id=mod-login-password”,
“Value”: “{!COL4}" }, { "Command": "clickAndWait", "Target": "//*[@id=\"form-login\"]/fieldset/div[3]/div/div/button", "Value": "" }, { "Command": "comment", "Target": "", "Value": "submit button from login" }, { "Command": "click", "Target": "link=Extensions", "Value": "" }, { "Command": "clickAndWait", "Target": "link=Plugins", "Value": "" }, { "Command": "click", "Target": "id=filter_search", "Value": "" }, { "Command": "type", "Target": "id=filter_search", "Value": "System - Update Notification" }, { "Command": "comment", "Target": "", "Value": "this is searching for the specific system update plugin" }, { "Command": "clickAndWait", "Target": "//*[@id=\"j-main-container\"]/div[1]/div[1]/div[1]/div[1]/button", "Value": "" }, { "Command": "comment", "Target": "", "Value": "submit button to search" }, { "Command": "click", "Target": "id=cb0", "Value": "" }, { "Command": "comment", "Target": "", "Value": "this is the checkbox for the plugin" }, { "Command": "click", "Target": "//*[@id=\"toolbar-unpublish\"]/button", "Value": "" }, { "Command": "comment", "Target": "", "Value": "this is the unpublish button" }, { "Command": "click", "Target": "link=User Menu", "Value": "" }, { "Command": "clickAndWait", "Target": "link=Logout", "Value": "" }, { "Command": "comment", "Target": "", "Value": "logs out of admin backend" }, { "Command": "storeEval", "Target": "{!csvReadLineNumber}+1”,
“Value”: “!csvReadLineNumber”
},
{
“Command”: “echo”,
“Target”: "Reading CSV line No. ${!csvReadLineNumber} ",
“Value”: “!errorIgnore”
},
{
“Command”: “csvRead”,
“Target”: “loopingtues1.csv”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “false”,
“Value”: “!errorIgnore”
},
{
“Command”: “endWhile”,
“Target”: “”,
“Value”: “”
},
{
“Command”: “localStorageExport”,
“Target”: “log”,
“Value”: “”
}
]
}

I’d like to force reading an entirely new line if a particular step fails,

So if there is an error during e. g. CSV data line 3, you want to macro to continue with CSV data from CSV file line 4?
But then the data from line 3 of the CSV is never processed, or?

Yes, exactly. So, if one step in the line fails, like a login doesn’t work, I’d ideally like it to log the error, then go to the next line in the csv entirely.

From what I’ve been reading, there could be something like this added?

If | {!statusOK} == false } <== logs error
echo | there was an error in loop ${!loop}
endif
GotoIf | {!statusOK} == false } | designated line <== Jumps to line on error

The issue though I’m having is two-fold:

  1. Is there a way to tell the program to do it globally, rather than at each step?
  2. Or if I have to do it at each step, I’d like to see how it could be accomplished, I’m a bit confused about the syntax. Say the following fails, how would I structure the GotoIf, etc to go to the end of the line directions? And where would I put the piece w/ the label? Would it be before the whole endwhile?

{
“Command”: “clickAndWait”,
“Target”: “/html/body/div[1]/form/button”,
“Value”: “”
},

{
“Command”: “comment”,
“Target”: “”,
“Value”: “submit button from rsfirewall, next step goes into main login”
},

Thank you much,

Stephanie

Hi Stephanie, have you find a solution?

I am not Stephanie, but the solution is to use the internal variable ${!csvReadLineNumber} - it has the current line number.

So what you do is to increase the variable by one:

executeScript_Sandbox | return Number (${!csvReadLineNumber} ) + 1; | !csvReadLineNumber

=> Now the next csvRead command reads the next line of the CSV!

Hi Plankton, i do executeScript_Sandbox | return Number (${!csvReadLineNumber} ) + 1; | !csvReadLineNumber and work, the next csvRead commands reads the next line of the CSV, but when i play macro, why at the end of data or text from CSV is add _1, _2, _3 etc, how to solve or delete that?