# Loop

Node type `browser_loop`

## What it does

Repeat a block by count, collection, element list, or condition.

## Desktop client configuration

![Loop configuration in the desktop client](/assets/loop.05af990d8a1370b3ba27df4f2866f602b0bf111eae56e77efd72402fe3cdc089.0538f3a9.webp)

Captured in the English interface of MoreLogin Desktop V2.73.101.

## Inputs

These fields belong in `data.browserUi.inputs`.

| Field | Type or values | Schema required | Execution default | Description and bounds |
|  --- | --- | --- | --- | --- |
| `loopMode` | `"times"` / `"elements"` / `"list"` / `"while"` (supports variable references) | No | `"times"` | Loop mode. Editor initial value `"times"` |
| `times` | `WorkflowNumber` | No | `3` | Loop Count; integer; minimum after resolution: 1; maximum after resolution: 10000. Editor initial value `3` |
| `selectorRadio` | `"CSS"` / `"XPath"` (supports variable references) | No | `"CSS"` | Selector type. Editor initial value `"CSS"` |
| `selector` | `string` | No | — | Selector |
| `serial` | `WorkflowNumber` | No | `1` | Element index; integer; minimum after resolution: 1. Editor initial value `1` |
| `type` | `"object"` / `"innerText"` / `"innerHTML"` / `"attribute"` / `"contentFrame"` (supports variable references) | No | `"innerText"` | Output type. Editor initial value `"innerText"` |
| `key` | `string` | No | — | Attribute name / child element selector |
| `content` | `["null","boolean","number","string"]` / array<`JSON`> / `object` (supports variable references) | No | — | List data |
| `loopConditions` | array<`object`> | No | — | While conditions are met |
| `maxIterations` | `WorkflowNumber` | No | `10000` | Maximum iterations; integer; minimum after resolution: 1; maximum after resolution: 10000. Editor initial value `10000` |
| `accumulatorMode` | `"none"` / `"collect"` / `"count"` / `"sum"` (supports variable references) | No | `"none"` | Accumulation mode. Editor initial value `"none"` |
| `initialState` | `["null","boolean","number","string"]` / array<`JSON`> / `object` (supports variable references) | No | — | Initial accumulated value |
| `accumulatorPath` | `string` | No | — | Accumulation field path (leave empty to use this iteration's result) |
| `breakEnabled` | `boolean` (supports variable references) | No | `false` | Early exit condition. Editor initial value `false` |
| `breakCondition` | `object` | No | — | Exit when met |


## Mode requirements and limits

- All four loop types enforce the maxIterations limit (a while loop that reaches the limit ends normally, with exitReason=max_iterations). accumulatorMode sets none/collect/count/sum (none when omitted), initialState sets the initial value, accumulatorPath reads a value inside the last node's data, and breakEnabled/breakCondition control early exit. For while, loopConditions accepts only a rule array [{field,operator,value}]. index starts at 1. For an object list, item={key,value}. type can only be object/innerText/innerHTML/attribute/contentFrame, and type=attribute requires key. A skipped branch does not reuse the previous iteration's output.
- Validation code `RPA_NODE_INPUT_INVALID`


## Input references

| Field | Allowed forms |
|  --- | --- |
| `loopMode` | `literal`, `template` |
| `times` | `literal`, `numericExpression` |
| `selectorRadio` | `literal`, `template` |
| `selector` | `literal`, `template` |
| `serial` | `literal`, `numericExpression` |
| `type` | `literal`, `template` |
| `key` | `literal`, `template` |
| `content` | `literal`, `template` |
| `loopConditions` | `literal` |
| `maxIterations` | `literal`, `numericExpression` |
| `accumulatorMode` | `literal`, `template` |
| `initialState` | `literal`, `template` |
| `accumulatorPath` | `literal`, `template` |
| `breakEnabled` | `literal`, `template` |
| `breakCondition` | `literal` |


## Outputs

| Output field | Type or values |
|  --- | --- |
| `index` | `number` / `null` |
| `item` | `["null","boolean","number","string"]` / array<`JSON`> / `object` |
| `total` | `number` |
| `iterationCount` | `number` |
| `completedCount` | `number` |
| `exited` | `boolean` |
| `state` | `["null","boolean","number","string"]` / array<`JSON`> / `object` |
| `results` | array<`["null","boolean","number","string"]` / array<`JSON`> / `object`> |
| `exitReason` | `"break"` / `"condition_false"` / `"max_iterations"` / `"completed"` |


Reference published fields as `${nodeId.data.field}`.

## JSON example

A complete node object for a workflow's `nodes` array or another node's `blocks`.

```json
{
  "id": "repeat_three_times",
  "type": "browser_loop",
  "data": {
    "title": "Repeat the check three times",
    "browserAction": "loop",
    "browserUi": {
      "inputs": {
        "loopMode": "times",
        "times": 3,
        "accumulatorMode": "none"
      }
    }
  },
  "blocks": [
    {
      "id": "reload_each_time",
      "type": "browser_refreshPage",
      "data": {
        "title": "Reload the page",
        "browserAction": "refreshPage",
        "browserUi": {
          "inputs": {
            "postWaitMs": 1000
          },
          "exception": {
            "timeout": 30000,
            "policy": "interrupt"
          }
        }
      }
    }
  ]
}
```

[Back to the node catalog](/browser-rpa/nodes)