Skip to main content
All variables live on a global env object. Access them anywhere a field accepts a string using {{ env.NAME }}, or directly as env.NAME inside JavaScript steps. See Environment variables for the full list of reserved variables and how Momentic loads them at runtime.

Example

Extract a value, then use it in a later step:
extract-order-id.test.yaml
fileType: momentic/test
name: extract-order-id
steps:
  - id: 01af...
    type: AI_ACTION
    text: Click "Place order"
  - id: 4f2d...
    type: PRESET_ACTION
    command:
      id: 2100...
      type: AI_EXTRACT
      goal: The order id shown in the confirmation banner
      envKey: ORDER_ID
  - id: b46c...
    type: PRESET_ACTION
    command:
      id: 5215...
      type: AI_ASSERTION
      assertion:
        A confirmation email mentioning order {{ env.ORDER_ID }} was sent

Setting variables

From JavaScript

setVariable("USERNAME", "testuser");
setVariable("PASSWORD", Math.random().toString(36).substring(2, 15));

From any step with a return value

Steps like AI extract and JavaScript expose a Save to environment variable option. Provide a key; the step’s return value is written to env after execution.
Save to environment variable

Scope

All variables are test-scoped. Set a variable in one step; any subsequent step in the same test can read it.

Module parameters

Module parameters are variables scoped to the module’s execution. A parameter named API_KEY is available as {{ env.API_KEY }} inside that module.