Docs
API 1.39
Status
Actions

when

The `when` step.

Runs do when a condition holds and else, if given, when it does not.

Type: condition

#Keys

KeyTypeDescription
when.doany[]The steps run when the condition holds, at least one.
when.elseany[]The steps run when the condition does not hold, at least one when present.

Every step also takes the common step keys: expect, id, if, name, on_error, optional, retry, side_effect, timeout_ms, x_kaab.

#Example

{
  "id": "otp",
  "when": {
    "visible": "#otp"
  },
  "do": [
    {
      "id": "ask-otp",
      "await_input": {
        "name": "otp",
        "prompt": "SMS code",
        "ttl": "5m",
        "expires": "24h",
        "collect": "hosted",
        "hosted": {
          "notify": "email",
          "to": "{{inputs.email}}"
        }
      }
    },
    {
      "id": "fill-otp",
      "fill": "#otp",
      "value": "{{vars.otp}}"
    },
    {
      "id": "confirm",
      "click": {
        "role": "button",
        "name": "Verify"
      },
      "side_effect": true,
      "expect": {
        "landmark": "logged_in"
      }
    }
  ]
}

From the contract fixture login-2fa-checkpoint-report, a program the test suite validates.

Was this page helpful?