Times loop issue: !loop stuck at 1, times command appears to re-execute (v9.5.3)

Hello UI.Vision Community,

I’m encountering a persistent and unusual issue with loops in UI.Vision RPA and would appreciate any insights or suggestions.

Environment:

  • UI.Vision RPA Version: 9.5.3 (freshly installed from Chrome Web Store)
  • Primary Browser: Google Chrome Version 136.0.7103.114 (Official Build)
  • Also tested in: Microsoft Edge (latest version, with only one other extension) - same issue occurs.
  • OS: Windows 11

Goal: I’m trying to iterate through rows of a CSV file to perform a set of actions for each row.

Problem Encountered: Both while and times loops are not functioning as expected. Even with the simplest test case using a times loop with a hardcoded number of iterations, the loop does not iterate its body correctly. Instead, the times command itself seems to re-execute, and the !loop variable (and !csvReadLineNumber) always remains at 1.

Minimal Reproducible Example (JSON): I created a new macro, pasted the following JSON directly into the “Source View (JSON)” tab, saved it, and ran it using the “Play Macro” button (Loop counter for “Play Loop” button is set to 1).

JSON{
  "Name": "TestLoopJSON",
  "CreationDate": "2025-05-21",
  "Commands": [
    {
      "Command": "times",
      "Target": "3",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "Current !loop is: ${!loop}",
      "Value": "green"
    },
    {
      "Command": "end",
      "Target": "",
      "Value": ""
    }
  ]
}

Expected Behavior (Log):

[info] Executing: | times | 3 |  | 
[info] Executing: | echo | Current !loop is: ${!loop} | green | 
[echo] Current !loop is: 1
[info] Executing: | echo | Current !loop is: ${!loop} | green | 
[echo] Current !loop is: 2
[info] Executing: | echo | Current !loop is: ${!loop} | green | 
[echo] Current !loop is: 3
[info] Executing: | end |  |  | 
[info] Macro completed

Actual Behavior (Log):

[info] Executing:  | times | 3 |  | 
[info] Executing:  | echo | Current !loop is: ${!loop} | green | 
[echo] Current !loop is: 1
[info] Executing:  | end |  |  | 
[info] Executing:  | times | 3 |  | 
[info] Executing:  | echo | Current !loop is: ${!loop} | green | 
[echo] Current !loop is: 1
[info] Executing:  | end |  |  | 
[info] Executing:  | times | 3 |  | 
[info] Executing:  | echo | Current !loop is: ${!loop} | green | 
[echo] Current !loop is: 1
[info] Executing:  | end |  |  | 
[info] Macro completed 

As you can see, the Executing: | times | 3 | | line appears 3 times, and !loop is always 1.

Troubleshooting Steps Taken:

  • Confirmed csvRead works correctly, and variables like !csvReadMaxRow, !COL1 (for the first row), and !csvReadLineNumber (initially 1) are populated as expected when testing with CSVs.
  • The issue is present even when using a hardcoded number in times (e.g., 3) instead of ${!csvReadMaxRow}.
  • Always using the “Play Macro” button, not “Play Loop” (Loop counter for “Play Loop” is 1).
  • The “Table View” of the UI.Vision editor initially had issues displaying commands from JSON, but after closing and reopening the editor, commands appear. In the simple test case, the echo command within the times block appears slightly indented in the Table View, suggesting a correct visual structure.
  • The problem is consistent across both Google Chrome and Microsoft Edge.
  • UI.Vision RPA is a fresh installation (today) of the latest version from the Chrome Web Store.

It seems like the UI.Vision execution engine on my system is not handling the times loop iteration correctly, causing the loop command itself to re-trigger instead of iterating its body with an incrementing !loop counter.

Question: Has anyone encountered similar behavior with times loops? What could be causing this (e.g., a specific bug in this version, an environmental factor)? Are there any further diagnostic steps or potential solutions I could try?

Any help would be greatly appreciated!

Thank you.

Hello everyone,

Thank you for your attention to my previous post about the unusual behavior of the times loop when using “Play Macro”. I described an issue where a simple macro like:

JSON{
  "Name": "TestLoopJSON",
  "Commands": [
    { "Command": "times", "Target": "3", "Value": "" },
    { "Command": "echo", "Target": "Current !loop is: ${!loop}", "Value": "green" },
    { "Command": "end", "Target": "", "Value": "" }
  ]
}

When run with “Play Macro”, would result in the Executing: | times | 3 | | line appearing multiple times in the log, and !loop always being 1 in the echo output for each of these apparent re-executions. This occurred in UI.Vision RPA v9.5.3 on Chrome v136.0.7103.114 (and also tested in Edge).

Update and Solution for CSV Processing Goal:

While the root cause of the times command behaving that way with “Play Macro” in my minimal test is still not entirely clear to me, I was able_to solve my underlying goal, which was to iterate through rows of a CSV file.

The solution was found by referring to the UI.Vision documentation regarding data-driven automation (specifically https://ui.vision/rpa/docs/selenium-ide/csvread).

The correct UI.Vision workflow for iterating through CSV files row by row is:

  1. Use the “Play Loop” button in the UI.Vision IDE.
  2. Set the “Max” value in the “Play Loop” settings to the number of rows in your CSV file.
  3. The macro script itself should not contain an internal times or while loop for iterating through the CSV rows. The “Play Loop” button handles the iteration.
  4. Inside the macro:
  • Start with csvRead | your_csv_file.csv.
  • The !loop variable (driven by the “Play Loop” button) will correctly increment for each pass (1, 2, 3…).
  • UI.Vision automatically sets !csvReadLineNumber to be equal to !loop.
  • !COL1, !COL2, etc., will then correctly provide the data for the current CSV row.

Example Macro for CSV iteration (run with “Play Loop”):

JSON{
  "Name": "ProcessMyCSV",
  "Commands": [
    {
      "Command": "csvRead",
      "Target": "my_data.csv", // Name of the CSV file
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "Processing row defined by 'Play Loop' !loop: ${!loop}. Data from !COL1: ${!COL1}. Current !csvReadLineNumber: ${!csvReadLineNumber}",
      "Value": "green"
    }
    // ... other commands to process the data for this row ...
  ]
}

When this macro is run by setting “Max” in “Play Loop” to the number of rows in my_data.csv and clicking the “Play Loop” button, it iterates through all rows correctly, with !loop, !csvReadLineNumber, and !COL1 updating as expected for each row.

Conclusion: For anyone facing issues trying to loop through CSV files using an internal times or while loop with “Play Macro”, the intended method is to remove that internal loop and use the “Play Loop” button as the driver for iteration. This solved my CSV processing requirement.

The specific reason for the unusual behavior of the times command in my initial minimal non-CSV test (when run with “Play Macro”) remains an open question, but for data-driven tasks from CSV files, the “Play Loop” approach is the correct and functional solution.

Thanks!

Hi Lukas,

I have a few while loops in my macro and have found the best way to automatically iterate through them is to use a ‘executeScript_Sandbox’ command at the end of your while loop. Lets assume your iterator is called row. The sandbox essentially lets you do something to the original variable (in this case adding 1 to it) and return the result to overwrite the variable (row) value.

{
  "Command": "store",
  "Target": "1",
  "Value": "row",
  "Description": "Iterator"
},
{
  "Command": "while",
  "Target": "${row} <= 5",
  "Value": "",
  "Description": ""
},
{ 
  Do something to CSV, etc////
},
{
  "Command": "executeScript_Sandbox",
  "Target": "return Number (${row}) + 1;",
  "Value": "row",
  "Description": "Increment the iterator to select the next row"
},
{
  "Command": "end",
  "Target": "",
  "Value": "",
  "Description": "End of While Loop"
}

Hope this helps.