Conditional Execution (If / Else / End)
The If block executes a sequence of actions only when a condition is met.Structure
Everyif block must be closed with an end block. An optional else block can be placed between them.
Condition Types
1. JavaScript Expression A JS expression evaluated in the browser page context. Must return a truthy/falsy value.| Helper | Description |
|---|---|
exists(selector) | Returns true if the element is found in the DOM |
text(selector) | Returns the text content of the first matching element |
url() | Returns the current page URL |
vars.name | Access a runtime variable by name |
block.output | The result of the previous action block |
html | The full page HTML as a string |
| Field | Description |
|---|---|
conditionVarType | string, number, or boolean |
conditionVar | Variable name or {$varName} reference |
conditionOp | Comparison operator (see table below) |
conditionValue | The value to compare against |
| Type | Operators |
|---|---|
| String | equals, not_equals, contains, starts_with, ends_with, matches (regex) |
| Number | equals, not_equals, gt, gte, lt, lte |
| Boolean | is_true, is_false |
Example: Login Check
Check whether the user is already logged in, and skip the login form if so:Nested Conditions
You can nestif blocks inside each other. Each nested block requires its own end:
While Loop
Executes a block of actions repeatedly as long as the condition remainstrue.
- Pagination: Click “next page” until there are no more pages.
- Polling: Wait for a specific element or state to appear.
- Retry logic: Re-attempt an action until it succeeds.
Foreach Loop
Iterates over all elements matching a CSS selector, executing the block once per element.| Variable | Description |
|---|---|
loop.index | Zero-based index of the current iteration |
loop.text | The full text content of the current element |
loop.html | The full HTML of the current element |
loop.item | Reference to the current element (for click/interact without a selector) |
Repeat N Times
Executes a block a fixed number of times regardless of any condition.loop.index variable is available inside repeat blocks (zero-based).
Example: Submit a form 3 times
Error Handling (On Error)
The On Error block acts like atry/catch. If any action in the main flow throws an error (timeout, element not found, network failure), execution jumps to the error handler block.
on_error/end block before an optional action effectively makes that action non-fatal.
See Error Handling for a deeper guide on retry patterns and resilient task design.
Stop Task
Immediately terminates the current task execution with a given status.stop inside conditionals to short-circuit execution when a goal is already met or when an unrecoverable state is detected.