Skip to main content
Figranium’s templating system allows for complex, dynamic automation by combining variables with JavaScript expressions and specialized helper functions.

JS Expression Support

In many action fields (like if conditions or set values), you can use full JavaScript expressions. These expressions have access to the current task’s state and variables. Example:
  • Condition: vars.count > 10 && exists('.next-page')
  • Calculation: {$index} * 100

Built-in JS Helpers

Inside JS expressions, Figranium provides several convenient helper functions:

exists(selector)

Returns true if the CSS selector matches any element on the page.

text(selector)

Returns the inner text of the first element matching the selector.

url()

Returns the current browser URL.

vars

A global object containing all defined task variables.

block.output

Contains the return value of the immediately preceding action.

html

The full page HTML as a string.
These helpers run in the browser page context, so they have access to the live DOM. Use exists() for quick element checks before clicks or waits.

Nested Variables

You can reference nested properties within objects or arrays using dot notation. Example:
  • Variable: user = { "profile": { "name": "Ada" } }
  • Template: Hello {$user.profile.name}

Loop Context Variables

Inside a foreach loop, the following special variables are available:

{$loop.index}

The current iteration index (starts at 0).

{$loop.count}

The total number of items being iterated.

{$loop.item}

The data object for the current row (if iterating over an array).

{$loop.text}

The text content of the current DOM element.

{$loop.html}

The inner HTML of the current element.

Handling Errors

Use the on_error block to define fallback logic. You can inspect the error message using {$block.output} inside the error handler to decide how to proceed.
JavaScript expressions are evaluated in the browser context. Avoid injecting user-controlled data directly into expressions to prevent unintended code execution.
Combine block.output with if conditions to create branching logic. For example, check block.output after a JavaScript block and route the task down different paths based on the returned value.